namespace BEGDC.CC.Web.UserControls.ECS
{
	using System;
	using System.Data;
	using System.Collections;
	using System.Drawing;
	using System.Web;
	using System.Text;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;

	using BEGDC.CC.BL.CCFlow.ECS;
	using BEGDC.CC.Entity;
	using BEGDC.CC.BL.Workflow;
	using BEGDC.CC.BL.Common;
	using BEGDC.CC.BL.Common.Query;
	using BEGDC.Utility.Castle;
	using BEGDC.CC.BL.UserManagement;

	public class ECSCtrl : BaseECS
	{
		#region VARIABLES DEFINITION
		protected System.Web.UI.WebControls.Label Lb_CISWarning;
		//protected System.Web.UI.WebControls.TextBox Ctl_TravelAgency;
		//protected System.Web.UI.WebControls.Label Lb_TravelAgency;
		protected System.Web.UI.WebControls.TextBox tbSomeoneName;
		protected System.Web.UI.WebControls.TextBox tbSomeoneEmail;
		protected System.Web.UI.WebControls.TextBox tbCustomerName;
		protected System.Web.UI.WebControls.RadioButtonList rbIsFCPA;
		protected System.Web.UI.WebControls.TextBox tbCustomerCountry;
		protected System.Web.UI.WebControls.RadioButtonList rbReviewGuideLine;
		protected System.Web.UI.WebControls.TextBox tbOtherLocation;
		protected System.Web.UI.WebControls.TextBox tbVisitObjectives;
		protected System.Web.UI.WebControls.CheckBoxList cblPreferredLocation;
		protected System.Web.UI.WebControls.TextBox tbPotentialRevenue;
		protected System.Web.UI.WebControls.DropDownList ddlPotentialRevenueTime;
		protected System.Web.UI.WebControls.DropDownList ddlSaleStage;
		protected System.Web.UI.WebControls.TextBox tbSensitiveIssues;
		protected System.Web.UI.WebControls.TextBox tbKeyMessage;
		protected System.Web.UI.WebControls.TextBox tbCompanyProfile;
		protected System.Web.UI.WebControls.DropDownList ddlAccountType;
		protected System.Web.UI.WebControls.TextBox tbProposalNo;
		protected System.Web.UI.WebControls.RadioButtonList rbSalesContract;
		protected System.Web.UI.WebControls.RadioButtonList rbSalesContractSigned;
		protected System.Web.UI.WebControls.TextBox tbNotSalesContractDescription;
		protected System.Web.UI.WebControls.RadioButtonList rbActivityInTrip;
		protected System.Web.UI.WebControls.TextBox tbRequestedDateFrom;
		protected System.Web.UI.WebControls.TextBox tbRequestedDateTo;
		protected System.Web.UI.WebControls.TextBox tbCustomerTeamHost;
		protected System.Web.UI.WebControls.TextBox tbCustomerOfficeTel;
		protected System.Web.UI.WebControls.TextBox tbCustomerFax;
		protected System.Web.UI.WebControls.TextBox tbCustomerEmail;
		protected System.Web.UI.WebControls.DropDownList ddlSalesBusinessUnit;
		protected System.Web.UI.WebControls.DropDownList ddlRegion;
		protected System.Web.UI.WebControls.TextBox tbDatesRequiredFrom;
		protected System.Web.UI.WebControls.TextBox tbDatesRequiredTo;
		protected System.Web.UI.WebControls.TextBox tbPreferEntertainment;
		protected System.Web.UI.WebControls.TextBox tbEntertainmentPriceRangeFrom;
		protected System.Web.UI.WebControls.TextBox tbEntertainmentPriceRangeTo;
		protected System.Web.UI.WebControls.RadioButtonList rbGiftNeed;
		protected System.Web.UI.WebControls.TextBox tbGiftPriceRangeFrom;
		protected System.Web.UI.WebControls.TextBox tbGiftPriceRangeTo;
		protected System.Web.UI.WebControls.RadioButtonList rbReceivedGift;
		protected System.Web.UI.WebControls.TextBox tbEstimateCostPerPerson;
		protected System.Web.UI.WebControls.RadioButtonList rbCateringService;
		protected System.Web.UI.WebControls.RadioButtonList RBL_KeyMessage;
		protected System.Web.UI.WebControls.TextBox tbCaterServiceExplain;
		protected System.Web.UI.WebControls.TextBox tbPreferGift;
		protected System.Web.UI.WebControls.TextBox tbEstimateTotalCost;
		protected System.Web.UI.WebControls.TextBox tbRequestorName;
		protected System.Web.UI.WebControls.TextBox tbRequestOfficeTel;
		protected System.Web.UI.WebControls.TextBox tbRequestorMobile;
		protected System.Web.UI.WebControls.TextBox tbSomeoneTel;
		protected System.Web.UI.WebControls.RadioButtonList rbEntertainmentNeed;
		protected System.Web.UI.WebControls.Literal litScript;
		protected System.Web.UI.WebControls.Label lbRequestorNameReadOnly;
		protected System.Web.UI.WebControls.Label lbRequestOfficeTelReadOnly;
		protected System.Web.UI.WebControls.Label lbRequestorMobileReadOnly;
		protected System.Web.UI.WebControls.Label lbSomeoneElseReadOnly;
		protected System.Web.UI.WebControls.Label lbSomeoneNameReadOnly;
		protected System.Web.UI.WebControls.Label lbSomeoneTelReadOnly;
		protected System.Web.UI.WebControls.Label lbSomeoneEmailReadOnly;
		protected System.Web.UI.WebControls.Label lbCustomerNameReadOnly;
		protected System.Web.UI.WebControls.Label lbIsFCPAReadOnly;
		protected System.Web.UI.WebControls.Label lbCustomerCountryReadOnly;
		protected System.Web.UI.WebControls.Label lbReviewGuideLineReadOnly;
		protected System.Web.UI.WebControls.Label lbPreferredLocationReadOnly;
		protected System.Web.UI.WebControls.Label lbOtherLocationReadOnly;
		protected System.Web.UI.WebControls.Label lbOtherCountryReadOnly;
		protected System.Web.UI.WebControls.Label lbGuestNumberReadOnly;
		protected System.Web.UI.WebControls.Label lbVisitObjectivesReadOnly;
		protected System.Web.UI.WebControls.Label lbPotentialRevenueReadOnly;
		protected System.Web.UI.WebControls.Label lbPotentialRevenueTimeReadOnly;
		protected System.Web.UI.WebControls.Label lbSaleStageReadOnly;
		protected System.Web.UI.WebControls.Label lbOutStandingRFPReadOnly;
		protected System.Web.UI.WebControls.Label lbSeneitiveIssuesReadOnly;
		protected System.Web.UI.WebControls.Label lbKeyMessageReadOnly;
		protected System.Web.UI.WebControls.Label lbCompanyProfileReadOnly;
		protected System.Web.UI.WebControls.Label lbAccountTypeReadOnly;
		protected System.Web.UI.WebControls.Label lbProposalNoReadOnly;
		protected System.Web.UI.WebControls.Label lbSalesContractReadOnly;
		protected System.Web.UI.WebControls.Label lbSalesContractSignedReadOnly;
		protected System.Web.UI.WebControls.Label lbNotSalesContractDescriptionReadOnly;
		protected System.Web.UI.WebControls.Label lbActivityInTripReadOnly;
		protected System.Web.UI.WebControls.Label lbRequestedDateFromReadOnly;
		protected System.Web.UI.WebControls.Label lbRequestedDateToReadOnly;
		protected System.Web.UI.WebControls.Label lbCustomerTeamHostReadOnly;
		protected System.Web.UI.WebControls.Label lbCustomerOfficeTelReadOnly;
		protected System.Web.UI.WebControls.Label lbCustomerFaxReadOnly;
		protected System.Web.UI.WebControls.Label lbCustomerEmailReadOnly;
		protected System.Web.UI.WebControls.Label lbSalesBusinessUnitReadOnly;
		protected System.Web.UI.WebControls.Label lbRegionReadOnly;
		protected System.Web.UI.WebControls.Label lbDatesRequiredFromReadOnly;
		protected System.Web.UI.WebControls.Label lbDatesRequiredToReadOnly;
		protected System.Web.UI.WebControls.Label lbEntertainmentNeedReadOnly;
		protected System.Web.UI.WebControls.Label lbPreferEntertainmentReadOnly;
		protected System.Web.UI.WebControls.Label lbEntertainmentPriceRangeFromReadOnly;
		protected System.Web.UI.WebControls.Label lbEntertainmentPriceRangeToReadOnly;
		protected System.Web.UI.WebControls.Label lbGiftNeedReadOnly;
		protected System.Web.UI.WebControls.Label lbPreferGiftReadOnly;
		protected System.Web.UI.WebControls.Label lbGiftPriceRangeFromReadOnly;
		protected System.Web.UI.WebControls.Label lbGiftPriceRangeToReadOnly;
		protected System.Web.UI.WebControls.Label lbReceivedGiftReadOnly;
		protected System.Web.UI.WebControls.Label lbEstimateTotalCostReadOnly;
		protected System.Web.UI.WebControls.Label lbEstimateCostPerPersonReadOnly;
		protected System.Web.UI.WebControls.Label lbCateringServiceReadOnly;
		protected System.Web.UI.WebControls.Label lbCaterServiceExplainReadOnly;
		protected System.Web.UI.HtmlControls.HtmlImage CustomerPaneImg;
		protected System.Web.UI.HtmlControls.HtmlImage ALPaneImg;
		protected System.Web.UI.HtmlControls.HtmlImage CostCenterPaneImg;
		protected System.Web.UI.HtmlControls.HtmlTableRow tr_Title;
		protected System.Web.UI.HtmlControls.HtmlTableRow tr_Button;
		protected System.Web.UI.HtmlControls.HtmlImage ContractDateImg;
		protected System.Web.UI.WebControls.RadioButtonList rbSomeoneElse;
		protected System.Web.UI.HtmlControls.HtmlGenericControl RequestedDateFromSpan;
		protected System.Web.UI.HtmlControls.HtmlGenericControl tbRequestedDateToSpan;
		protected System.Web.UI.HtmlControls.HtmlGenericControl RequestedDateFromspan;
		protected System.Web.UI.HtmlControls.HtmlGenericControl tbDatesRequiredFromSpan;
		protected System.Web.UI.HtmlControls.HtmlGenericControl tbDatesRequiredToSpan;

		protected System.Web.UI.HtmlControls.HtmlGenericControl span1;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span2;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span3;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span4;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span5;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span6;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span7;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span8;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span9;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span10;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span11;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span12;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span13;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span14;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span15;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span16;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span17;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span18;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span19;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span20;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span21;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span22;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span23;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span24;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span25;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span26;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span27;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span28;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span29;
		protected System.Web.UI.HtmlControls.HtmlGenericControl span30;

		protected System.Web.UI.WebControls.DropDownList Dp_Department;
		protected System.Web.UI.WebControls.DataGrid dgContractInfo;
		protected System.Web.UI.HtmlControls.HtmlImage ConrtractInfoPane;
		protected BEGDC.CC.Web.Control.UserSearchControl SearchStaff;
		protected System.Web.UI.HtmlControls.HtmlTable Table_Contract;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_Catering;
		protected System.Web.UI.WebControls.DataGrid dgCustomerList;
		protected System.Web.UI.WebControls.DataGrid dgALAttendee;
		protected System.Web.UI.WebControls.DataGrid dgCostCenter;
		protected System.Web.UI.HtmlControls.HtmlImage HotelBookingImg;
		protected System.Web.UI.HtmlControls.HtmlImage CompanyCarImg;
		protected System.Web.UI.HtmlControls.HtmlImage LeaseCarImg;
		protected System.Web.UI.WebControls.Label Lb_RFPDetails;
		//protected System.Web.UI.WebControls.TextBox Ctl_RFPDetails;
		protected System.Web.UI.WebControls.RadioButtonList RB_IsSensitiveIssue;
		//protected System.Web.UI.WebControls.TextBox Ctl_DetailedItinerary;
		protected System.Web.UI.WebControls.Label Lb_DetailedItinerary;
		protected System.Web.UI.WebControls.TextBox tbTopic;
		protected System.Web.UI.WebControls.Label lbTopicReadOnly;
		protected System.Web.UI.WebControls.RadioButtonList RBL_Meal;
		protected System.Web.UI.WebControls.TextBox Ctl_MealContent;
		protected System.Web.UI.WebControls.Label tx_MealContent;
		protected System.Web.UI.WebControls.Label LB_MealEachCost;
		//protected System.Web.UI.WebControls.TextBox Ctl_ArrivalFlightNo;
		//protected System.Web.UI.WebControls.Label tx_ArrivalFightNo;
		//protected System.Web.UI.WebControls.TextBox Ctl_ArrivalAirport;
		//protected System.Web.UI.WebControls.Label tx_ArrivalAirport;
		//protected System.Web.UI.WebControls.TextBox ArrivalTime;
		//protected System.Web.UI.WebControls.Label tx_ArrivalTime;
		//protected System.Web.UI.WebControls.TextBox Ctl_LeaveFlightNo;
		//protected System.Web.UI.WebControls.Label tx_LeaveFightNo;
		//protected System.Web.UI.WebControls.TextBox Ctl_LeaveAirport;
		//protected System.Web.UI.WebControls.Label tx_LeaveAirport;
		//protected System.Web.UI.WebControls.TextBox LeaveTime;
		//protected System.Web.UI.WebControls.Label tx_LeaveTime;
		//protected System.Web.UI.HtmlControls.HtmlGenericControl ArrivalTimeSpan;
		//protected System.Web.UI.HtmlControls.HtmlGenericControl LeaveTimeSpan;
		protected System.Web.UI.WebControls.TextBox Ctl_GiftsDetails;
		protected System.Web.UI.WebControls.Label Lb_GiftDetails;
		protected System.Web.UI.WebControls.RadioButtonList RB_IsTravelAgency;
		protected System.Web.UI.WebControls.Label Lb_IsTravelAgency;
		protected System.Web.UI.WebControls.RadioButtonList RBL_message;
		protected System.Web.UI.HtmlControls.HtmlTableRow MealReservationPane;
		protected System.Web.UI.WebControls.TextBox Ctl_HRID;
		protected System.Web.UI.WebControls.Label LB_HRID;
		protected System.Web.UI.WebControls.TextBox Ctl_SomeoneMobil;
		protected System.Web.UI.WebControls.Label Lb_SomeoneMobil;
		protected System.Web.UI.WebControls.Label lbIsSensitiveIssue;
		protected System.Web.UI.WebControls.Label lbKeyMessage;
		protected System.Web.UI.WebControls.Label Lb_IsMealReservation;
		//protected System.Web.UI.HtmlControls.HtmlTableRow TR_Account;
		protected System.Web.UI.WebControls.Label lbContractSum;
		protected System.Web.UI.WebControls.Label lbCostSum;
		protected System.Web.UI.WebControls.DataGrid dgHotel;
		protected System.Web.UI.WebControls.DataGrid dgCompanyCar;
		protected System.Web.UI.WebControls.DataGrid dgLeaseCar;
		protected System.Web.UI.WebControls.Label lbEZVisitNoReadOnly;
		protected System.Web.UI.WebControls.Label lbLGDNoReadOnly;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_ID;
		protected System.Web.UI.WebControls.DropDownList ddlLegalEntity;
		protected System.Web.UI.WebControls.Label lblLegalEntity;
		protected System.Web.UI.WebControls.Label lbSummaryReadOnly;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_Knowledge;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_KnowledgeTitle;
		protected System.Web.UI.WebControls.TextBox Ctl_LogisticComment;
		protected System.Web.UI.WebControls.Label lbLogisticComment;
		protected System.Web.UI.WebControls.Label lbExpenseTypeReadOnly;
		protected System.Web.UI.WebControls.DropDownList Dp_ExpenseType;
		protected System.Web.UI.WebControls.TextBox HiddenGiftAttachment;
		protected System.Web.UI.WebControls.DropDownList Dp_PaymentForHotel;
		protected System.Web.UI.WebControls.Label tx_PaymentForHotel;
		protected System.Web.UI.WebControls.RadioButtonList rbOutStandingRFP;
		protected System.Web.UI.WebControls.Label lbBUHeadApproval;
		protected System.Web.UI.WebControls.RadioButtonList rbBUHeadApproval;

		protected System.Web.UI.HtmlControls.HtmlTableRow TR_PotentialEuros;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_TimeFrame;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_NeedRFP;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_SalesStage;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_SensitiveIssue;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_Keymessage;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_TrackingNo;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_Visa;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_LodgingDate;
		protected System.Web.UI.HtmlControls.HtmlTableRow HotelPriceRange;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_MealReservation;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_CounselApprovalTitle;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_CounselApproval;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_WhoPaying;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_DirectProvider;
		protected System.Web.UI.HtmlControls.HtmlTableRow TR_NoDirectReason;

		protected System.Web.UI.WebControls.RadioButtonList rbALInvitation;
		protected System.Web.UI.WebControls.Label lbALInvitationReadOnly;
		protected System.Web.UI.WebControls.DropDownList ddlPayingFor;
		protected System.Web.UI.WebControls.Label lbPayingForReadOnly;
		protected System.Web.UI.WebControls.RadioButtonList rbDirectToProvider;
		protected System.Web.UI.WebControls.Label lbDirectToProviderReadOnly;
		protected System.Web.UI.HtmlControls.HtmlGenericControl img4;
		protected System.Web.UI.HtmlControls.HtmlGenericControl img5;
		protected System.Web.UI.WebControls.RadioButtonList rbECS;
		protected System.Web.UI.WebControls.Label tx_ECS;
		protected System.Web.UI.WebControls.Label tx_Department;
		protected System.Web.UI.WebControls.Label tx_CostCenter;
		protected System.Web.UI.WebControls.DropDownList Dp_CostCenter;
		protected System.Web.UI.WebControls.RadioButtonList rbInterpreterRequired;
		protected System.Web.UI.WebControls.Label lbInterpreferRequiredReadOnly;
		protected System.Web.UI.WebControls.RadioButtonList rbSimultaneousConsecutive;
		protected System.Web.UI.WebControls.Label lbSimultaneousConsecutiveReadOnly;
		protected System.Web.UI.WebControls.RadioButtonList rbSpecialDialect;
		protected System.Web.UI.WebControls.Label lbSpecialDialectReadOnly;
		protected System.Web.UI.WebControls.TextBox tbPriceRangeFrom;
		protected System.Web.UI.WebControls.Label lbPriceRangeFromReadOnly;
		protected System.Web.UI.WebControls.TextBox tbPriceRangeTo;
		protected System.Web.UI.WebControls.Label lbPriceRangeToReadOnly;
		//protected System.Web.UI.HtmlControls.HtmlGenericControl span8;
		//protected System.Web.UI.HtmlControls.HtmlGenericControl span9;
		protected System.Web.UI.WebControls.TextBox tbNotDirectReason;
		protected System.Web.UI.WebControls.Label lbNotDirectReasonReadOnly;
		protected System.Web.UI.WebControls.RadioButtonList rbHotelRequired;
		protected System.Web.UI.WebControls.Label lbHotelRequiredReadOnly;
		protected System.Web.UI.WebControls.RadioButtonList rbTransportationRequired;
		protected System.Web.UI.WebControls.Label lbTransportationRequiredReadOnly;
		private bool _isReadOnly = false;
		protected System.Web.UI.WebControls.TextBox tbPerDiem;
		protected System.Web.UI.WebControls.Label lbPerDiemReadOnly;
		protected System.Web.UI.WebControls.TextBox tbPaymentRemark;
		protected System.Web.UI.WebControls.Label lbPaymentRemarkReadOnly;
		protected BEGDC.CC.Web.UserControls.ECS.CloseCtl closectl1;
		protected System.Web.UI.WebControls.TextBox Ctl_MealEachCost;
		protected System.Web.UI.WebControls.TextBox checkSomeone;
		protected System.Web.UI.WebControls.TextBox tbCustomerCount;
		private bool _isKnowledgeVisible = false;
		#endregion

		#region Properties
		private bool IsQuery
		{
			get
			{
				string state = this.Request.QueryString["State"];
				if(state == null) return false;
				return state == SysDicItem.ProjectStatusFlag.QUERY;
			}
		}
		public bool isCoveredPerson
		{
			get
			{ 
				string str = (string)this.ViewState["ISCOVEREDPERSON"];
				if(str == "1")
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			set
			{ 
				if(value)
				{
					this.ViewState["ISCOVEREDPERSON"] = "1";
				}
				else
				{
					this.ViewState["ISCOVEREDPERSON"] = "0";
				}
			}
		}
		public bool KnowledgeVisible
		{
			set
			{
				_isKnowledgeVisible = value;
			}
			get
			{
				return _isKnowledgeVisible;
			}
		}
		public string RequestDateFrom
		{
			get
			{
				return this.tbRequestedDateFrom.Text;
			}
		}
		public string RequestDateTo
		{
			get
			{
				return this.tbRequestedDateTo.Text;
			}
		}
		public bool isReadOnly
		{
			set
			{
				_isReadOnly = value;
			}
			get
			{
				return _isReadOnly;
			}
		}
		public bool isNeedGift
		{
			get
			{
				return this.rbGiftNeed.SelectedValue == "1";
			}
		}
		public bool isNeedHotel
		{
			get
			{
				return this.rbHotelRequired.SelectedValue == "1";
			}
		}
		public bool isNeedVehicle
		{
			get
			{
				return this.rbTransportationRequired.SelectedValue == "1";
			}
		}
		public bool isNeedVisa
		{
			get
			{
				return this.rbALInvitation.SelectedValue == "1";
			}
		}
		public CheckBoxList VisitingSiteControl
		{
			get
			{
				return this.cblPreferredLocation;
			}
		}
		public string OtherSiteLocation
		{
			get
			{
				return this.tbOtherLocation.Text;
			}
		}
		public int CustomerID
		{
			set
			{
				ViewState["customerID"] = value;
			}
			get
			{
				if(ViewState["customerID"] == null)
					return 0;
				return Convert.ToInt32(ViewState["customerID"]);
			}
		}
		public int BusinessID
		{
			set
			{
				ViewState["businessID"] = value;
			}
			get
			{
				if(ViewState["businessID"] == null)
					return 0;
				return Convert.ToInt32(ViewState["businessID"]);
			}
		}
		public int TopicID
		{
			set
			{
				ViewState["topicID"] = value;
			}
			get
			{
				if(ViewState["topicID"] == null)
					return 0;
				return Convert.ToInt32(ViewState["topicID"]);
			}
		}
		public int SalesTeamID
		{
			set
			{
				ViewState["salesTeamID"] = value;
			}
			get
			{
				if(ViewState["salesTeamID"] == null)
					return 0;
				return Convert.ToInt32(ViewState["salesTeamID"]);
			}
		}
		public int LogistID
		{
			set
			{
				ViewState["logistID"] = value;
			}
			get
			{
				if(ViewState["logistID"] == null)
					return 0;
				return Convert.ToInt32(ViewState["logistID"]);
			}
		}
		public int PaymentID
		{
			set
			{
				ViewState["paymentID"] = value;
			}
			get
			{
				if(ViewState["paymentID"] == null)
					return 0;
				return Convert.ToInt32(ViewState["paymentID"]);
			}
		}

		public string Dp_Dept_Value
		{
			get
			{
				return this.Dp_Department.SelectedItem.Value.ToString();
			}
		}
		public string Dp_CostCenter_Value
		{
			get
			{
				return this.Dp_CostCenter.SelectedItem.Value.ToString();
			}
		}
		protected string ApplicationNo
		{
			get
			{ 
				if( this.ViewState["ApplicationNo"] == null )
					return string.Empty;
				return this.ViewState["ApplicationNo"].ToString(); 
			}
			set{ this.ViewState["ApplicationNo"] = value; }
		}
		private bool IsView
		{
			get
			{
				string state = this.Request.QueryString["State"];
				if(state == null) return false;
				if(state == SysDicItem.ProjectStatusFlag.QUERY || state == SysDicItem.ProjectStatusFlag.View
					|| state == SysDicItem.ProjectStatusFlag.Pending || state == SysDicItem.ProjectStatusFlag.End)
					return true;
				else
					return false;
			}
		}
		private string _step = string.Empty;
		protected string Step
		{
			get
			{
				IQuery queryService = BEGDC.Utility.Castle.AppContainer.Instance[BEGDC.CC.BL.Common.ServiceConst.QueryService] as IQuery;
				FlowInstance flowInstance = queryService.QueryFlowInstance( this.AppID );
				if( flowInstance == null )
					return "Close";
				else
				{
					_step = flowInstance.CurrentStep.StepCode;
					return flowInstance.CurrentActiveStep.StepCode;
				}
			}
		}

		public int CustomerNum
		{
			get
			{
				if(this.dgCustomerList!=null)
					return this.dgCustomerList.Items.Count;
				else
					return 0;
			}
		}

		public int AccompanyNum
		{
			get
			{
				if(this.dgALAttendee!=null)
					return this.dgALAttendee.Items.Count;
				else
					return 0;
			}
		}

		public int HotelNum
		{
			get
			{
				if(this.dgHotel!=null)
					return this.dgHotel.Items.Count;
				else
					return 0;
			}
		}

		public int CostCenterNum
		{
			get
			{
				if(this.dgCostCenter!=null)
					return this.dgCostCenter.Items.Count;
				else
					return 0;
			}
		}

		public bool IsSomeoneElse
		{
			get
			{
				if(this.rbSomeoneElse.SelectedValue=="1")
				{
					return true;
				}
				else
				{
					return false;
				}
			}
		}
		public bool IsCustomerNotInCIS
		{
			get
			{
				return this.Lb_CISWarning.Visible;
			}
		}


		public BEGDC.CC.Entity.Employee SomeoneEmployee
		{
			get
			{
				if(this.SearchStaff.EmployeeID!="")
				{
					return this.GetUserById(this.SearchStaff.EmployeeID);
				}
				else
				{
					return null;
				}
			}
		}
		#endregion

		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!Page.IsPostBack)
			{
				Session[SessionFlag.AccompanySessionEZ] = null;
				Session[SessionFlag.CustomerSessionEZ] = null;
				Session[SessionFlag.ContractInfo] = null;
				Session[SessionFlag.CostCenter] = null;
				Session[SessionFlag.AccompanySession] = null;
				Session[SessionFlag.CustomerSession] = null;
				Session[SessionFlag.MeetingMinutesAttendee] = null;

				this.TR_Knowledge.Visible = false;
				this.TR_KnowledgeTitle.Visible  =false;

				PreInitFormControls();
				InitialDropDownList();
				BindApplication();

				#region TextBox CheckNum
				this.tbPriceRangeFrom.Attributes["onkeypress"] = "javascript: return CheckNum('tbPriceRangeFrom',event);";
				this.tbPriceRangeTo.Attributes["onkeypress"] = "javascript: return CheckNum('tbPriceRangeTo',event);";
				this.Ctl_MealEachCost.Attributes["onkeypress"] = "javascript: return CheckNum('Ctl_MealEachCost',event);";
				this.tbEntertainmentPriceRangeFrom.Attributes["onkeypress"] = "javascript: return CheckNum('tbEntertainmentPriceRangeFrom',event);";
				this.tbEntertainmentPriceRangeTo.Attributes["onkeypress"] = "javascript: return CheckNum('tbEntertainmentPriceRangeTo',event);";	
				this.tbGiftPriceRangeFrom.Attributes["onkeypress"] = "javascript: return CheckNum('tbGiftPriceRangeFrom',event);";
				this.tbGiftPriceRangeTo.Attributes["onkeypress"] = "javascript: return CheckNum('tbGiftPriceRangeTo',event);";
				#endregion

				#region Radio List OnClick
				this.rbECS.Attributes["onclick"] = "javascript:ShowECS();";
				this.rbSomeoneElse.Attributes["onclick"] = "javascript:ShowSomeOneElsePane();";
				//this.rbOutStandingRFP.Attributes["onclick"] = "javascript:ShowRFPDetailPane();";
				this.RB_IsSensitiveIssue.Attributes["onclick"] = "javascript:ShowSensitiveIssuePane();";
				this.RBL_KeyMessage.Attributes["onclick"] = "javascript:ShowKeyMessageDetailPane();";

				this.rbSalesContract.Attributes["onclick"] = "javascript:ShowSalesContractPane();";
				this.rbSalesContractSigned.Attributes["onclick"] = "javascript:ShowSalesContractSignedPane();";
				//this.rbActivityInTrip.Attributes["onclick"] = "javascript:ShowActivityInTripPane();";

				this.RBL_Meal.Attributes["onclick"] = "javascript:ShowRBL_MealPane();";
				this.rbEntertainmentNeed.Attributes["onclick"] = "javascript:ShowEntertainmentNeedPane();";
				this.rbGiftNeed.Attributes["onclick"] = "javascript:ShowGiftNeedPane();";
				this.rbReceivedGift.Attributes["onclick"] = "javascript:ShowReceivedGiftPane();";
				this.RB_IsTravelAgency.Attributes["onclick"] = "javascript:ShowTravelAgencyPane();";
				this.rbCateringService.Attributes["onclick"] = "javascript:ShowCateringServicePane();";

				//<--joan 2007/08/12
				this.rbHotelRequired.Attributes["onclick"] = "javascript:ShowHotelPart();";
				//-->end
				//this.cblPreferredLocation.Attributes["onclick"] = "javascript:ShowVisitingSite();";
				this.rbTransportationRequired.Attributes["onclick"] = "javascript:ShowVehiclePart();";
				this.rbDirectToProvider.Attributes["onclick"] = "javascript:ShowServiceProviderPane();";
				#endregion
			}
			else
			{
				#region RELOAD DATAGRID
				BindCustomerAttendee();
				BindALAttendee();
				BindCostCenter();
				BindContractInfo();

				DataTable HotelDataTable = null;
				object SessHotelBooking = Session[SessionFlag.HotelSessionEZ];
				if(SessHotelBooking!=null)
				{
					HotelDataTable = (DataTable)SessHotelBooking;
					this.dgHotel.DataSource = HotelDataTable;
					this.dgHotel.DataBind();
				}
				DataTable CompanyCarDataTable = null;
				object SessCompanyCarBooking = Session[SessionFlag.CompanyCarSessionEZ];
				if(SessCompanyCarBooking!=null)
				{
					CompanyCarDataTable = (DataTable)SessCompanyCarBooking;
					this.dgCompanyCar.DataSource = CompanyCarDataTable;
					this.dgCompanyCar.DataBind();
				}
				DataTable LeaseCarDataTable = null;
				object SessLeaseCarBooking = Session[SessionFlag.LeaseCarSessionEZ];
				if(SessLeaseCarBooking!=null)
				{
					LeaseCarDataTable = (DataTable)SessLeaseCarBooking;
					this.dgLeaseCar.DataSource = LeaseCarDataTable;
					this.dgLeaseCar.DataBind();
				}
				#endregion
				this.closectl1.BindCostCenter();
			}
//			Page.SmartNavigation = true;
			ShowBlock();

			if(this.Step == WorkTransition.ECS_CloseApp || this.Step == WorkTransition.End)
			{
				this.closectl1.Visible = true;
				this.closectl1.isCoveredPerson = this.isCoveredPerson;
			}
			else
			{
				this.closectl1.Visible = false;
			}

			if(this.Step == WorkTransition.ECS_ReRequest || (this.IsQuery && _step != WorkTransition.ECS_AssignApp))
				this.DisableEditECS();
		}

		#region ShowBlock
		private void ShowBlock()
		{
			StringBuilder sb = new StringBuilder();
			if(!Page.IsStartupScriptRegistered("ECSCtrl_Startup"))
			{
				sb.Append( "<script language=\"javascript\">\n");
				if(this.isReadOnly)
				{
					sb.Append( "DisplayECSPane("+this.rbECS.SelectedValue+");\n");
					sb.Append( "DisplaySomeOneElsePane("+this.rbSomeoneElse.SelectedValue+");\n");
					if(this.isCoveredPerson)
					{
						//sb.Append( "DisplayRFPDetailPane("+this.rbOutStandingRFP.SelectedValue+");\n");
						sb.Append( "DisplaySensitiveIssuePane("+this.RB_IsSensitiveIssue.SelectedValue+");\n");
						sb.Append( "DisplayKeyMessageDetailPane("+this.RBL_KeyMessage.SelectedValue+");\n");
						sb.Append( "DisplayRBL_MealPane("+this.RBL_Meal.SelectedValue+");\n");
						sb.Append( "DisplayServiceProviderPane("+this.rbDirectToProvider.SelectedValue+");\n");
					}
					sb.Append( "DisplayEntertainmentNeedPane("+this.rbEntertainmentNeed.SelectedValue+");\n");
					sb.Append( "DisplayGiftNeedPane("+this.rbGiftNeed.SelectedValue+");\n");
					sb.Append( "DisplayReceivedGiftPane("+this.rbReceivedGift.SelectedValue+");\n");
					//sb.Append( "DisplayActivityInTripPane("+this.rbActivityInTrip.SelectedValue+");\n");
					//sb.Append( "DisplayTravelAgencyPane("+this.RB_IsTravelAgency.SelectedValue+");\n");
					sb.Append( "DisplaySalesContractPane("+this.rbSalesContract.SelectedValue+");\n");
					sb.Append( "DisplaySalesContractSignedPane("+this.rbSalesContractSigned.SelectedValue+");\n");
					sb.Append( "DisplayHotelPart("+this.rbHotelRequired.SelectedValue+");\n");
					sb.Append( "DisplayVehiclePart("+this.rbTransportationRequired.SelectedValue+");\n");
					sb.Append( "DisplayCateringServicePane("+this.rbCateringService.SelectedValue+");\n");
					//sb.Append( "DisplayVisitingSitePane("+this.rbCateringService.SelectedValue+");\n");
					sb.Append( "_ShowInterpreterPane("+this.rbInterpreterRequired.SelectedValue+");\n");
				}
				else
				{
					sb.Append( "ShowECS();\n");
					sb.Append( "ShowSomeOneElsePane();\n");
					if(this.isCoveredPerson)
					{
						//sb.Append( "ShowRFPDetailPane();\n");
						sb.Append( "ShowSensitiveIssuePane();\n");
						sb.Append( "ShowKeyMessageDetailPane();\n");
						sb.Append( "ShowRBL_MealPane();\n");
						sb.Append( "ShowServiceProviderPane();\n");
					}
					sb.Append( "ShowEntertainmentNeedPane();\n");
					sb.Append( "ShowGiftNeedPane();\n");
					sb.Append( "ShowReceivedGiftPane();\n");
					//sb.Append( "ShowActivityInTripPane();\n");
					sb.Append( "ShowSalesContractPane();\n");
					//sb.Append( "ShowTravelAgencyPane();\n");
					sb.Append( "ShowSalesContractPane();\n");
					sb.Append( "ShowHotelPart();\n");
					sb.Append( "ShowVehiclePart();\n");
					sb.Append( "ShowCateringServicePane();\n");
					sb.Append( "ShowInterpreterPane();");
					//sb.Append( "ShowVisitingSite();\n");
				}
				sb.Append("</script>\n");

				Page.RegisterStartupScript("ECSCtrl_Startup",sb.ToString());
			}
		}
		#endregion

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.rbSomeoneElse.SelectedIndexChanged += new System.EventHandler(this.rbSomeoneElse_SelectedIndexChanged);
			this.rbSalesContractSigned.SelectedIndexChanged += new System.EventHandler(this.Contract_Select);
			this.dgContractInfo.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgContractInfo_DeleteCommand);
			this.dgContractInfo.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgContractInfo_ItemDataBound);
			this.dgCustomerList.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgCustomerList_DeleteCommand);
			this.dgCustomerList.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgCustomerList_ItemDataBound);
			this.dgALAttendee.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgALAttendee_DeleteCommand);
			this.dgALAttendee.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgALAttendee_ItemDataBound);
			this.dgHotel.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.EZHotelList_DeleteCommand);
			this.dgHotel.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.EZHotelDataBound);
			this.dgCompanyCar.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.EZCompanyCarDeleteCommand);
			this.dgCompanyCar.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.EZCompanyCarDataBound);
			this.dgLeaseCar.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.EZLeaseCarDeleteCommand);
			this.dgLeaseCar.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.EZLeaseCarDataBound);
			this.dgCostCenter.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgCostCenter_DeleteCommand);
			this.dgCostCenter.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgCostCenter_ItemDataBound);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		#region PreInitFormControls
		private void PreInitFormControls()
		{
			if(this.Application!=null)
			{
				this.isCoveredPerson = !this.Application.IsTransition;
			}
			if(!this.isCoveredPerson)
			{
				this.TR_PotentialEuros.Visible = false;
				this.TR_TimeFrame.Visible = false;
				this.TR_SalesStage.Visible = false;
				this.TR_NeedRFP.Visible = false;
				this.TR_SensitiveIssue.Visible = false;
				this.TR_Keymessage.Visible = false;
				this.TR_TrackingNo.Visible = false;
				this.TR_Visa.Visible = false;
				this.TR_LodgingDate.Visible = false;
				this.HotelPriceRange.Visible = false;
				this.TR_MealReservation.Visible = false;
				this.TR_CounselApprovalTitle.Visible = false;
				this.TR_CounselApproval.Visible = false;
				this.TR_WhoPaying.Visible = false;
				this.TR_DirectProvider.Visible = false;
				this.TR_NoDirectReason.Visible = false;

				//this.Ctl_RFPDetails.Visible = false;
				this.tbSensitiveIssues.Visible = false;
				this.tbKeyMessage.Visible = false;
				this.rbIsFCPA.Enabled = false;
			}
		}
		#endregion

		#region InitialDropDownList
		private void InitialDropDownList()
		{
			IQuery queryService = BEGDC.Utility.Castle.AppContainer.Instance[BEGDC.CC.BL.Common.ServiceConst.QueryService] as IQuery;

			WebUtility.BuildDropDown(Dp_Department,BEGDC.CC.BL.Common.DicType.NONSSEMDepartment,false,false);
			WebUtility.BuildDropDown(Dp_CostCenter,BEGDC.CC.BL.Common.DicType.CostCenter,false,false);

			WebUtility.BuildDropDown(ddlPotentialRevenueTime,BEGDC.CC.BL.Common.DicType.POTENTIAL_REVENUE_TIMEFRAME,false,false);
			WebUtility.BuildDropDown(ddlSaleStage,BEGDC.CC.BL.Common.DicType.SALES_STAGE,false,false);
			WebUtility.BuildDropDown(ddlAccountType,BEGDC.CC.BL.Common.DicType.ACCOUNT_TYPE,false,false);

			WebUtility.BuildDropDown(ddlSalesBusinessUnit,BEGDC.CC.BL.Common.DicType.SALES_BUSINESS_UNIT_OCO,false,false);
			WebUtility.BuildDropDown(ddlRegion,BEGDC.CC.BL.Common.DicType.REGION_OCO,false,false);

			//WebUtility.BuildDropDown(this.Dp_MeetingRoom,BEGDC.CC.BL.Common.DicType.MeetingRoom,false,false);
			WebUtility.BuildDropDown(this.Dp_ExpenseType,BEGDC.CC.BL.Common.DicType.ExpenseType,false,false);
			WebUtility.BuildDropDown(this.Dp_PaymentForHotel,BEGDC.CC.BL.Common.DicType.PaymentForHotel,false,false);

			WebUtility.BuildDropDown(ddlPayingFor,BEGDC.CC.BL.Common.DicType.PAYER,false,false);
			WebUtility.BuildCheckBoxList(cblPreferredLocation,BEGDC.CC.BL.Common.DicType.OCOVisitingSites);

			BEGDC.CC.BL.Common.IUtility utility = AppContainer.Instance[ServiceConst.UtilityService] as BEGDC.CC.BL.Common.IUtility;
			IList DeptList = utility.BuildDicList(BEGDC.CC.BL.Common.DicType.BRANCH);

			//init legal entity
			this.ddlLegalEntity.DataSource = queryService.GetAllLegalEntity();
			this.ddlLegalEntity.DataTextField = "LegalEntityName";
			this.ddlLegalEntity.DataValueField = "LegalEntityID";
			this.ddlLegalEntity.DataBind();
		}
		#endregion

		#region BindApplication

		private void BuildDepartmentCATList()
		{
			BEGDC.CC.BL.Common.Query.IQuery queryService = AppContainer.Instance[ServiceConst.QueryService] as BEGDC.CC.BL.Common.Query.IQuery;
			DataTable catTable = queryService.GetDeptByTypeName( BEGDC.CC.BL.Common.DicType.CAT );
			DataTable branchTable = queryService.GetDeptByTypeName( BEGDC.CC.BL.Common.DicType.BRANCH );

			DataRow[] rows = catTable.Select();
			foreach( DataRow row in rows )
			{
				branchTable.ImportRow(row);
			}

			this.Dp_Department.DataSource = branchTable;
			this.Dp_Department.DataValueField = "DepartmentCode";
			this.Dp_Department.DataTextField = "DepartmentCode";
			this.Dp_Department.DataBind();

			this.Dp_Department.Items.Insert(this.Dp_Department.Items.Count,new System.Web.UI.WebControls.ListItem("Other Department","OTH"));

			if(this.Dp_Department.Items.Count>0)
			{
				this.Dp_Department.Items[0].Selected = true;
			}

			// Initialize Account Dropdown List
//			DataTable accountTable = queryService.GetDicItemByTypeName( BEGDC.CC.BL.Common.DicType.ACCOUNT );
//			this.Dp_Account.DataSource = accountTable.DefaultView;
//			this.Dp_Account.DataValueField = "DicItemKey";
//			this.Dp_Account.DataTextField = "DicItemKey";
//			this.Dp_Account.DataBind();
//
//			if(this.Dp_Account.Items.Count>0)
//			{
//				this.Dp_Account.Items[0].Selected = true;
//			}
		}


		private void BindApplication()
		{
			this.LoadApplication();

			//BuildDepartmentCATList();

			if(this.Application!=null)
			{
				if(this.Application.EZVisitReqNo!=""||this.Application.LGDNo!="")
				{
					this.lbEZVisitNoReadOnly.Text = this.Application.EZVisitReqNo;
					this.lbLGDNoReadOnly.Text = this.Application.LGDNo;
					this.TR_ID.Visible = true;
				}
				else
				{
					this.TR_ID.Visible = false;
				}
			}
			else
			{
				this.TR_ID.Visible = false;
			}

			Employee CurrentUser = this.GetUser(HttpContext.Current.User.Identity.Name);

			if(this.AppID == 0)
			{
				BindHotelData(null);
				BindCompanyCarData(null);
				BindLeaseCarData(null);
				BindContractInfo();
				BindCustomerAttendee();
				BindALAttendee();
				BindCostCenter();

				if(CurrentUser!=null)
				{
					this.tbRequestorName.Text = CurrentUser.NameEN;
					//Employee emp = this.GetUser(HttpContext.Current.User.Identity.Name);
					//this.lbDepartmentReadOnly.Text = CurrentUser.Department.DepartmentCode;
				}
				return;
			}

			IQuery queryService = AppContainer.Instance[ServiceConst.QueryService] as IQuery;
			CustomerInfo customer = queryService.GetCustomerInfo(this.AppID);
			BusinessPurpose business = queryService.GetBusinessPurposeInfo(this.AppID);
			Topic topic = queryService.GetTopicInfo(this.AppID);
			SalesTeamInfo salesTeam = queryService.GetSalesTeamInfo(this.AppID);
			LogisticalInfo logist = queryService.GetLogisticalInfo(this.AppID);
			PaymentInfo payment = queryService.GetPaymentInfo(this.AppID);
			DataTable visitingSite = queryService.GetVisitingSite(this.AppID);

			this.CustomerID = customer.Id;
			this.BusinessID = business.Id;
			this.TopicID = topic.Id;
			this.SalesTeamID = salesTeam.Id;
			this.LogistID = logist.Id;
			this.PaymentID = payment.Id;

			BindApplicationData(visitingSite);
			BindCustomerInfoData(customer);
			BindBusinessPurposeData(business);
			BindTopicData(topic);
			BindSalesTeamData(salesTeam);
			BindLogisticalData(logist);
			BindHotelData(logist);
			BindCompanyCarData(logist);
			BindLeaseCarData(logist);
			BindPaymentData(payment);

			BindCustomerAttendee();
			BindALAttendee();
			BindCostCenter();
			BindContractInfo();

			if(this.isReadOnly)
				BindReadOnlyStatus();
		}

		private Employee GetUser(string name)
		{
			IUser userService = AppContainer.Instance[ServiceConst.UserService] as IUser;
			return userService.GetUser(name);
		}

		private Employee GetUserById(string Id)
		{
			IUser userService = AppContainer.Instance[ServiceConst.UserService] as IUser;
			return userService.GetUserByID(Id);
		}

		private void BindApplicationData(DataTable site)
		{
			this.tbRequestorName.Text = this.Application.RequesterNameEN;
			this.tbRequestOfficeTel.Text = this.Application.RequesterOfficeTel;
			this.tbRequestorMobile.Text = this.Application.RequesterMobile;
			this.rbReviewGuideLine.SelectedValue = this.Application.IsReviewedGuideline? "1":"0";
			this.tbOtherLocation.Text = this.Application.OtherSite;
			if(this.isCoveredPerson)
			{ 
				this.rbBUHeadApproval.SelectedValue = this.Application.BUHeadApproved? "1":"0";
			}
			this.rbECS.SelectedValue = this.Application.IsSSME? "1":"0";
			if(this.Application.IsSSME)
			{
				this.Dp_CostCenter.SelectedValue = this.Application.CostCenterCode.Id.ToString();
			}
			else
			{
				this.Dp_Department.SelectedValue = this.Application.DepartmentType.Id.ToString();
			}

			if(this.Application.RequestedDateFrom!=null)
			{
				this.tbRequestedDateFrom.Text = ((DateTime)this.Application.RequestedDateFrom).ToString("MM/dd/yyyy");
			}
			if(this.Application.RequestedDateTo!=null)
			{
				this.tbRequestedDateTo.Text = ((DateTime)this.Application.RequestedDateTo).ToString("MM/dd/yyyy");
			}
//			if(this.Application.AlternateDateFrom != null)
//			{
//				this.tbAlternateDateFrom.Text = ((DateTime)this.Application.AlternateDateFrom).ToString("MM/dd/yyyy");
//			}
//			if(this.Application.AlternateDateTo != null)
//			{
//				this.tbAlternateDateTo.Text = ((DateTime)this.Application.AlternateDateTo).ToString("MM/dd/yyyy");
//			}
			if( this.Application.LegalEntity != null )
			{
				this.ddlLegalEntity.SelectedValue = Application.LegalEntity.Id.ToString();
			}
			if(this.KnowledgeVisible)
			{
				this.TR_Knowledge.Visible = true;
				this.TR_KnowledgeTitle.Visible  =true;
				this.lbSummaryReadOnly.Text = this.Application.Summary;
			}

			//this.lbDepartmentReadOnly.Text = this.Application.DepartmentName.DepartmentCode;
			this.ApplicationNo = this.Application.AppNo;

			this.rbSomeoneElse.SelectedValue = this.Application.ApplyForSomeoneElse? "1":"0";
			if(this.Application.ApplyForSomeoneElse)
			{
				this.Ctl_HRID.Text = this.Application.SomeoneElseHRID;
				if(this.Application.SomeoneElseNo!=null)
				{
					this.SearchStaff.EmployeeID = this.Application.SomeoneElseNo.Id;
					this.SearchStaff.EmployeeName = this.Application.SomeoneElseNameEN;
				}
				this.tbSomeoneTel.Text = this.Application.SomeoneElseTel;
				this.Ctl_SomeoneMobil.Text = this.Application.SomeoneElseMobil;
				this.tbSomeoneEmail.Text = this.Application.SomeoneElseEmail;
			}

			if(site != null && site.Rows.Count > 0)
			{
				for(int i=0; i<site.Rows.Count; i++)
					for(int j=0; j<this.cblPreferredLocation.Items.Count; j++)
					{
						if(site.Rows[i]["DicItemID"].ToString() == cblPreferredLocation.Items[j].Value)
							cblPreferredLocation.Items[j].Selected = true;
					}
			}				
		}

		private void BindCustomerInfoData(CustomerInfo customer)
		{
			if(customer != null)
			{
				this.tbCustomerName.Text = customer.Company;
				this.rbIsFCPA.SelectedValue = customer.IsFCPA? "1":"0";
				this.tbCustomerCountry.Text = customer.Country;
				this.tbVisitObjectives.Text = customer.VisitObjective;

				if(this.isCoveredPerson)
				{
					this.tbPotentialRevenue.Text = customer.DecryptedRevenuePotential.ToString();
					this.ddlPotentialRevenueTime.SelectedValue = customer.PotentialRevenueTimeframe.ToString();
					this.ddlSaleStage.SelectedValue = customer.SalesStage.ToString();
					this.rbOutStandingRFP.SelectedValue = customer.IsInRFP? "1":"0"; 
					//this.Ctl_RFPDetails.Text = customer.RFPDetail;
					this.RB_IsSensitiveIssue.SelectedValue = customer.IsSensitiveIssue? "1":"0"; 
					this.tbSensitiveIssues.Text = customer.IsThereSensitiveIssue;
					this.RBL_KeyMessage.SelectedValue = customer.IsKeyMessage? "1":"0";
					this.tbKeyMessage.Text = customer.IsThereKeyMessage;
					this.tbProposalNo.Text = customer.ProposalNo;
				}

				this.tbCompanyProfile.Text = customer.CompanyProfile;
				this.ddlAccountType.SelectedValue = customer.AccountType.Id.ToString(); 
			}
		}

		private void BindBusinessPurposeData(BusinessPurpose business)
		{
			if(business != null)
			{
				this.rbSalesContract.SelectedValue = business.IsInSalesContract? "1":"0";
				this.rbSalesContractSigned.SelectedValue = business.IsContractSigned? "1":"0"; 
				this.rbActivityInTrip.SelectedValue = business.RecreationalActivity? "1":"0";
				if(this.isCoveredPerson)
				{
					this.rbALInvitation.SelectedValue = business.IsNeedInvitationLetter? "1":"0";
				}
				//this.Ctl_DetailedItinerary.Text = business.Itinerary;
				this.tbNotSalesContractDescription.Text = business.Opportunities;
			}
		}

		private void BindTopicData(Topic topic)
		{
			if(topic != null)
			{
				this.tbTopic.Text = topic.TopicName;
			}
		}

		private void BindSalesTeamData(SalesTeamInfo salesTeam)
		{
			if(salesTeam != null)
			{
				this.tbCustomerTeamHost.Text = salesTeam.HostNameEN;
				this.tbCustomerOfficeTel.Text = salesTeam.OfficeTel;
				this.tbCustomerFax.Text = salesTeam.OfficeFax;
				this.tbCustomerEmail.Text = salesTeam.Email;
				this.ddlSalesBusinessUnit.SelectedValue = salesTeam.SalesBusinessUnit;
				this.ddlRegion.SelectedValue = salesTeam.Region;
			}
		}

		private void BindLogisticalData(LogisticalInfo logist)
		{
			if(logist != null)
			{
				this.rbHotelRequired.SelectedValue = logist.IsNeedHotel? "1":"0";

				if(this.isCoveredPerson)
				{
					if(logist.DateRequiredFrom!=null)
					{
						this.tbDatesRequiredFrom.Text = ((DateTime)logist.DateRequiredFrom).ToString("MM/dd/yyyy");
					}
					if(logist.DateRequiredTo!=null)
					{
						this.tbDatesRequiredTo.Text = ((DateTime)logist.DateRequiredTo).ToString("MM/dd/yyyy");
					}
					this.RBL_Meal.SelectedValue = logist.IsMealReservation? "1":"0";
					this.Ctl_MealContent.Text = logist.MealReservation;
					this.Ctl_MealEachCost.Text = logist.AverageMealCost.ToString();

					this.tbPriceRangeFrom.Text = logist.DecryptedPriceFrom.ToString();
					this.tbPriceRangeTo.Text = logist.DecryptedPriceTo.ToString();
				}
				this.Dp_PaymentForHotel.SelectedValue = logist.PaymentForHotel.Id.ToString();
				this.rbTransportationRequired.SelectedValue = logist.IsNeedGroundTransportation? "1":"0";
				this.Ctl_LogisticComment.Text = logist.Comment;

				//Arrival Fight No
				//this.Ctl_ArrivalFlightNo.Text = logist.ArrivalFlightNo;
				//this.Ctl_ArrivalAirport.Text = logist.ArrivalAirport;
				//if(logist.ArrivalTime!=null&&logist.ArrivalTime!="")
				//{
					//this.ArrivalTime.Text = ((DateTime)logist.ArrivalTime).ToString("MM/dd/yyyy");
				//}

//				if(logist.MeetingRoom!=null)
//				{
//					this.Dp_MeetingRoom.SelectedIndex = Dp_MeetingRoom.Items.IndexOf(Dp_MeetingRoom.Items.FindByValue(logist.MeetingRoom.Id.ToString()));
//				}

				//Leave Fight No
				//this.Ctl_LeaveFlightNo.Text = logist.DepartureFlightNo;
				//this.Ctl_LeaveAirport.Text = logist.DepartureAirport;
				//if(logist.DepartureTime!=null&&logist.DepartureTime!="")
				//{
					//this.LeaveTime.Text = ((DateTime)logist.DepartureTime).ToString("MM/dd/yyyy");
				//}

				this.rbEntertainmentNeed.SelectedValue = logist.IsNeedEntertainment? "1":"0";
				this.tbPreferEntertainment.Text = logist.EntertainmentPreference;
				this.tbEntertainmentPriceRangeFrom.Text = logist.DecryptedEntertainmentPriceFrom.ToString();
				this.tbEntertainmentPriceRangeTo.Text = logist.DecryptedEntertainmentPriceTo.ToString();

				this.tbGiftPriceRangeFrom.Text = logist.DecryptedGiftPriceFrom.ToString();
				this.tbGiftPriceRangeTo.Text = logist.DecryptedGiftPriceTo.ToString();

				this.rbGiftNeed.SelectedValue = logist.IsNeedGift? "1":"0"; 
				this.tbPreferGift.Text = logist.GiftDetails;

				this.rbReceivedGift.SelectedValue = logist.IsReceivedALGiftBefore? "1":"0";
				this.Ctl_GiftsDetails.Text = logist.ReceivedGiftDetails;
				this.rbInterpreterRequired.SelectedValue = logist.IsNeedInterpreter? "1":"0";
				this.rbSimultaneousConsecutive.SelectedValue = logist.InterpretionType.ToString();
				this.rbSpecialDialect.SelectedValue = logist.SpecialDialect;

				this.rbCateringService.SelectedValue = logist.IsNeedCatering? "1":"0";
				this.tbCaterServiceExplain.Text = logist.CateringDescription;
				this.RB_IsTravelAgency.SelectedValue = logist.IsNeedTravelAgency? "1":"0";
				//this.Ctl_TravelAgency.Text = logist.TravelAgency;
			}
		}

		private void BindHotelData(LogisticalInfo LogisticalInfo)
		{
			//LOAD HOTEL LIST
			IECS ECSService = AppContainer.Instance[ServiceConst.ECSService] as IECS;
			DataTable HotelDataTable = null;
			if(Session[SessionFlag.HotelSessionEZ]!=null)
			{
				object SessHotelBooking = Session[SessionFlag.HotelSessionEZ];
				HotelDataTable = (DataTable)SessHotelBooking;
				this.dgHotel.DataSource = HotelDataTable;
				this.dgHotel.DataBind();
			}
			else
			{
				if(LogisticalInfo!=null)
				{
					HotelDataTable = ECSService.GetHotelRoomBookingList(LogisticalInfo.Id);
				}
				if(HotelDataTable!=null&&HotelDataTable.Rows.Count>0)
				{
					Session[SessionFlag.HotelSessionEZ] = HotelDataTable;
					//this.DG_Hotel.DataSource = HotelDataTable;
					//this.DG_Hotel.DataBind();
				}
				else
				{
					HotelDataTable = new DataTable();
					HotelDataTable.Columns.Add(new DataColumn("Id", typeof(System.String)));
					HotelDataTable.Columns.Add(new DataColumn("HotelId", typeof(System.String)));
					HotelDataTable.Columns.Add(new DataColumn("HotelName", typeof(System.String)));
					HotelDataTable.Columns.Add(new DataColumn("RoomTypeId", typeof(System.String)));
					HotelDataTable.Columns.Add(new DataColumn("RoomTypeName", typeof(System.String)));
					HotelDataTable.Columns.Add(new DataColumn("RoomNumber", typeof(System.String)));
					Session[SessionFlag.HotelSessionEZ] = HotelDataTable;
				}
				this.dgHotel.DataSource = HotelDataTable;
				this.dgHotel.DataBind();
			}
		}

		private void BindCompanyCarData(LogisticalInfo LogisticalInfo)
		{
			//LOAD COMPANY CAR LIST
			IECS ECSService = AppContainer.Instance[ServiceConst.ECSService] as IECS;
			DataTable CompanyCarDataTable = null;
			object SessCompanyCarBooking = Session[SessionFlag.CompanyCarSessionEZ];
			if(SessCompanyCarBooking!=null)
			{
				CompanyCarDataTable = (DataTable)SessCompanyCarBooking;
				this.dgCompanyCar.DataSource = CompanyCarDataTable;
				this.dgCompanyCar.DataBind();
			}
			else
			{
				if(LogisticalInfo!=null)
				{
					CompanyCarDataTable = ECSService.GetVehicleBookingList(LogisticalInfo.Id,BEGDC.CC.BL.Common.DicType.AlcatelCar);
				}
				if(CompanyCarDataTable!=null&&CompanyCarDataTable.Rows.Count>0)
				{
					Session[SessionFlag.CompanyCarSessionEZ] = CompanyCarDataTable;
				}
				else
				{
					CompanyCarDataTable = new DataTable();
					CompanyCarDataTable.Columns.Add(new DataColumn("Id", typeof(System.String)));
					CompanyCarDataTable.Columns.Add(new DataColumn("VehicleTypeId", typeof(System.String)));
					CompanyCarDataTable.Columns.Add(new DataColumn("VehicleType", typeof(System.String)));
					CompanyCarDataTable.Columns.Add(new DataColumn("VehicleNumber", typeof(System.String)));
					Session[SessionFlag.CompanyCarSessionEZ] = CompanyCarDataTable;
				}
				this.dgCompanyCar.DataSource = CompanyCarDataTable;
				this.dgCompanyCar.DataBind();
			}
		}

		private void BindLeaseCarData(LogisticalInfo LogisticalInfo)
		{
			//LOAD LEASE CAR LIST
			IECS ECSService = AppContainer.Instance[ServiceConst.ECSService] as IECS;
			DataTable LeaseCarDataTable = null;
			object SessLeaseCarBooking = Session[SessionFlag.LeaseCarSessionEZ];
			if(SessLeaseCarBooking!=null)
			{
				LeaseCarDataTable = (DataTable)SessLeaseCarBooking;
				this.dgLeaseCar.DataSource = LeaseCarDataTable;
				this.dgLeaseCar.DataBind();
			}
			else
			{
				if(LogisticalInfo!=null)
				{
					LeaseCarDataTable = ECSService.GetVehicleBookingList(LogisticalInfo.Id,BEGDC.CC.BL.Common.DicType.LeaseCar);
				}
				if(LeaseCarDataTable!=null&&LeaseCarDataTable.Rows.Count>0)
				{
					Session[SessionFlag.LeaseCarSessionEZ] = LeaseCarDataTable;
				}
				else
				{
					LeaseCarDataTable = new DataTable();
					LeaseCarDataTable.Columns.Add(new DataColumn("Id", typeof(System.String)));
					LeaseCarDataTable.Columns.Add(new DataColumn("VehicleTypeId", typeof(System.String)));
					LeaseCarDataTable.Columns.Add(new DataColumn("VehicleType", typeof(System.String)));
					LeaseCarDataTable.Columns.Add(new DataColumn("VehicleNumber", typeof(System.String)));
					Session[SessionFlag.LeaseCarSessionEZ] = LeaseCarDataTable;
				}
				this.dgLeaseCar.DataSource = LeaseCarDataTable;
				this.dgLeaseCar.DataBind();
			}
		}

		private void BindPaymentData(PaymentInfo payment)
		{
			if(payment != null)
			{
				if(this.isCoveredPerson)
				{
					this.ddlPayingFor.SelectedValue = payment.Payer.ToString();
					this.rbDirectToProvider.SelectedValue = payment.IsPayServiceProvider? "1":"0";
					this.tbNotDirectReason.Text = payment.NotDirectPayReasons;
				}
				this.tbPerDiem.Text = payment.CustomerPerdiem;
				this.tbPaymentRemark.Text = payment.Comments;
				this.tbEstimateTotalCost.Text = payment.DecryptedEstimatedCustomerTotalCost.ToString();
				this.tbEstimateCostPerPerson.Text = payment.DecryptedEstimateCustomerdIndividualCost.ToString();
				this.Dp_ExpenseType.SelectedIndex = Dp_ExpenseType.Items.IndexOf(Dp_ExpenseType.Items.FindByValue(payment.ExpenseType.Id.ToString()));
			}
		}

		private void BindContractInfo()
		{
			DataTable ContractInfo = null;
			if(Session[SessionFlag.ContractInfo] != null)
			{
				ContractInfo = (DataTable)Session[SessionFlag.ContractInfo];
			}
			else
			{
				if(this.AppID > 0)
				{
					IQuery queryService = AppContainer.Instance[ServiceConst.QueryService] as IQuery;
					ContractInfo = SetRowID(queryService.QueryContractInfoByAppId(this.AppID));
				}
				if(ContractInfo == null || ContractInfo.Rows.Count == 0)
				{
					ContractInfo = new DataTable();
					ContractInfo.Columns.Add(new DataColumn("RowId", typeof(System.String)));
					ContractInfo.Columns.Add(new DataColumn("DateOfContract", typeof(System.DateTime)));
					ContractInfo.Columns.Add(new DataColumn("ContractNo", typeof(System.String)));
					ContractInfo.Columns.Add(new DataColumn("ProducstSold", typeof(System.String)));
					ContractInfo.Columns.Add(new DataColumn("VisitPurposeInContract", typeof(System.String)));
					ContractInfo.Columns.Add(new DataColumn("Quotas", typeof(System.Int32)));
					ContractInfo.Columns.Add(new DataColumn("UnitPrice", typeof(System.Decimal)));
					ContractInfo.Columns.Add(new DataColumn("Budget", typeof(System.Decimal)));
				}
				Session[SessionFlag.ContractInfo] = ContractInfo;
			}
			this.dgContractInfo.DataSource = this.SetRowID(ContractInfo);
			this.dgContractInfo.DataBind();

			this.lbContractSum.Text = CalculateSum();
		}

		private DataTable SetRowID(DataTable table)
		{
			if(table != null && table.Rows.Count >0)
				for(int i=1; i<=table.Rows.Count; i++)
				{
					table.Rows[i-1][0] = i.ToString();
				}
			return table;
		}
		#endregion

		#region BindCustomerAttendee
		private void BindCustomerAttendee()
		{
			DataTable CustomerDataTable = null;
			object SessCustomerAttendee = Session[SessionFlag.CustomerSessionEZ];
			if(SessCustomerAttendee!=null)
			{
				CustomerDataTable = (DataTable)SessCustomerAttendee;
			}
			else
			{
				IQuery queryService = AppContainer.Instance[ServiceConst.QueryService] as IQuery;
				if(this.CustomerID > 0)
				{
					CustomerDataTable = queryService.GetCustomerAttendeeList(this.CustomerID);
				}
				if(CustomerDataTable!=null&&CustomerDataTable.Rows.Count>0)
				{
					//add by yuliang for adding column "AttendeeCount" to CustomerDataTable
					if(!CustomerDataTable.Columns.Contains("AttendeeCount"))
					{
						CustomerDataTable.Columns.Add(new DataColumn("AttendeeCount", typeof(System.Int32)));

						foreach(DataRow dr in CustomerDataTable.Rows)
						{
							dr["AttendeeCount"] = queryService.GetCustomerAttendeeCountForOversea(dr["Name"].ToString(),dr["Company"].ToString());
						}
					}

					Session[SessionFlag.CustomerSessionEZ] = CustomerDataTable;
				}
				else
				{
					CustomerDataTable = new DataTable();
					CustomerDataTable.Columns.Add(new DataColumn("Id", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("Name", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("Company", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("Title", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("NameCN", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("CompanyEN", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("TitleEN", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("Responsibility", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("Affects", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("ResponsibilityID", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("AffectsID", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("Remark", typeof(System.String)));
					CustomerDataTable.Columns.Add(new DataColumn("IsExisted", typeof(System.String)));
					Session[SessionFlag.CustomerSessionEZ] = CustomerDataTable;
				}
			}
			this.dgCustomerList.DataSource = this.SetRowID(CustomerDataTable);
			this.dgCustomerList.DataBind();
			if(CheckCISCustomer())
			{
				this.Lb_CISWarning.Visible = true;
			}
			else
			{
				this.Lb_CISWarning.Visible = false;
			}
			if(CustomerDataTable!=null&&CustomerDataTable.Rows.Count>0)
			{
				this.lbGuestNumberReadOnly.Text = CustomerDataTable.Rows.Count.ToString();
			}
			else
			{
				this.lbGuestNumberReadOnly.Text = "0";
			}

			// Auto calculate cost per person
			this.litScript.Visible = true;
			this.litScript.Text = string.Empty;
			this.litScript.Text = "<script>SetCustomerCount("+CustomerDataTable.Rows.Count.ToString()+");CalculateCostPerPerson();</script>";
		}
		#endregion

		#region BindALAttendee
		private void BindALAttendee()
		{
			DataTable AccompanyingAttendee = null;
			if(Session[SessionFlag.AccompanySessionEZ] != null)
			{
				AccompanyingAttendee = (DataTable)Session[SessionFlag.AccompanySessionEZ];
			}
			else
			{
				if(this.AppID > 0)
				{
					IECS ECSService = AppContainer.Instance[ServiceConst.ECSService] as IECS;
					AccompanyingAttendee = ECSService.GetAccompanyingAttendeeList(this.AppID);
				}
				if(AccompanyingAttendee == null || AccompanyingAttendee.Rows.Count == 0)
				{
					AccompanyingAttendee = new DataTable();
					AccompanyingAttendee.Columns.Add(new DataColumn("Id", typeof(System.String)));
					AccompanyingAttendee.Columns.Add(new DataColumn("EmployeeId", typeof(System.String)));
					AccompanyingAttendee.Columns.Add(new DataColumn("Name", typeof(System.String)));
					AccompanyingAttendee.Columns.Add(new DataColumn("Title", typeof(System.String)));
				}
				Session[SessionFlag.AccompanySessionEZ] = AccompanyingAttendee;
			}
			this.dgALAttendee.DataSource = this.SetRowID(AccompanyingAttendee);
			this.dgALAttendee.DataBind();
		}
		#endregion

		#region BindCostCenter
		private void BindCostCenter()
		{
			DataTable CostCenter = null;
			if(Session[SessionFlag.CostCenter] != null)
			{
				CostCenter = (DataTable)Session[SessionFlag.CostCenter];
			}
			else
			{
				if(this.PaymentID > 0)
				{
					IQuery queryService = AppContainer.Instance[ServiceConst.QueryService] as IQuery;
					CostCenter = queryService.GetCostCenter(this.PaymentID);
				}
				if(CostCenter == null || CostCenter.Rows.Count == 0)
				{
					CostCenter = new DataTable();
					CostCenter.Columns.Add(new DataColumn("Id", typeof(System.String)));
					CostCenter.Columns.Add(new DataColumn("CostCenterCode", typeof(System.String)));
					CostCenter.Columns.Add(new DataColumn("Cost", typeof(System.String)));
					CostCenter.Columns.Add(new DataColumn("ActualCost", typeof(System.String)));
					CostCenter.Columns.Add(new DataColumn("ActualTransferCost", typeof(System.String)));
				}
				Session[SessionFlag.CostCenter] = CostCenter;
			}
			this.dgCostCenter.DataSource = this.SetRowID(CostCenter);
			this.dgCostCenter.DataBind();

			this.lbCostSum.Text = this.CalculateCostSum();
		}
		#endregion

		#region BindReadOnlyStatus
		private void BindReadOnlyStatus()
		{
			this.ALPaneImg.Visible = false;
			this.CustomerPaneImg.Visible = false;
			this.CostCenterPaneImg.Visible = false;
			this.ConrtractInfoPane.Visible = false;
			// Application
			this.tbRequestorName.Visible = false;
			this.lbRequestorNameReadOnly.Text = this.tbRequestorName.Text;
			this.tbRequestOfficeTel.Visible = false;
			this.lbRequestOfficeTelReadOnly.Text = this.tbRequestOfficeTel.Text;
			this.tbRequestorMobile.Visible = false;
			this.lbRequestorMobileReadOnly.Text = this.tbRequestorMobile.Text;
			this.ddlLegalEntity.Visible = false;
			this.lblLegalEntity.Text = this.ddlLegalEntity.SelectedItem.Text;

			this.span1.Visible = false;
			this.span2.Visible = false;
			this.span3.Visible = false;
			this.span4.Visible = false;
			this.span5.Visible = false;
			this.span6.Visible = false;
			this.span7.Visible = false;
			this.span8.Visible = false;
			this.span9.Visible = false;
			this.span10.Visible = false;
			this.span11.Visible = false;
			this.span12.Visible = false;
			this.span13.Visible = false;
			this.span14.Visible = false;
			this.span15.Visible = false;
			this.span16.Visible = false;
			this.span17.Visible = false;
			this.span18.Visible = false;
			this.span19.Visible = false;
			this.span20.Visible = false;
			this.span21.Visible = false;
			this.span22.Visible = false;
			this.span23.Visible = false;
			this.span24.Visible = false;
			this.span25.Visible = false;
			this.span26.Visible = false;
			this.span27.Visible = false;
			this.span28.Visible = false;
			this.span29.Visible = false;
			this.span30.Visible = false;
//          this.Dp_Department.Visible = false;
//			if(this.Dp_Department.SelectedItem!=null)
//			{
//				this.tx_AllDepts.Text = this.Dp_Department.SelectedValue;
//			}
//			this.Dp_Account.Visible = false;
//			if(this.Dp_Account.SelectedItem!=null)
//			{
//				this.tx_Account.Text = this.Dp_Account.SelectedValue;
//			}

			this.rbReviewGuideLine.Visible = false;
			this.lbReviewGuideLineReadOnly.Text = this.rbReviewGuideLine.SelectedItem.Text;
			this.tbOtherLocation.Visible = false;
			this.lbOtherLocationReadOnly.Text = this.tbOtherLocation.Text;
			this.tbRequestedDateFrom.Visible = false;
			this.lbRequestedDateFromReadOnly.Text = this.tbRequestedDateFrom.Text;
			this.tbRequestedDateTo.Visible = false;
			this.lbRequestedDateToReadOnly.Text = this.tbRequestedDateTo.Text;
//			this.tbAlternateDateFrom.Visible = false;
//			this.lbAlternateDateFromReadOnly.Text = this.tbAlternateDateFrom.Text;
//			this.tbAlternateDateTo.Visible = false;
//			this.lbAlternateDateToReadOnly.Text = this.tbAlternateDateTo.Text;

			this.Ctl_HRID.Visible = false;
			this.LB_HRID.Text = this.Ctl_HRID.Text;
			this.rbSomeoneElse.Visible = false;
			this.lbSomeoneElseReadOnly.Text = this.rbSomeoneElse.SelectedItem.Text;
			this.SearchStaff.Visible = false;
			this.lbSomeoneNameReadOnly.Text = this.SearchStaff.EmployeeName;
			this.Ctl_SomeoneMobil.Visible = false;
			this.Lb_SomeoneMobil.Text = this.Ctl_SomeoneMobil.Text;
			this.tbSomeoneTel.Visible = false;
			this.lbSomeoneTelReadOnly.Text = this.tbSomeoneTel.Text;
			this.tbSomeoneEmail.Visible = false;
			this.lbSomeoneEmailReadOnly.Text = this.tbSomeoneEmail.Text;
			this.cblPreferredLocation.Visible = false;
			for(int i=0; i<this.cblPreferredLocation.Items.Count; i++)
				if(cblPreferredLocation.Items[i].Selected)
					this.lbPreferredLocationReadOnly.Text += cblPreferredLocation.Items[i].Text + ",";
			string temp = this.lbPreferredLocationReadOnly.Text;
			if(temp != string.Empty)
				this.lbPreferredLocationReadOnly.Text = temp.Substring(0, temp.Length -1);
            //ContractDateImg.Visible = false;

			this.rbBUHeadApproval.Visible = false;
			this.lbBUHeadApproval.Text = this.rbBUHeadApproval.SelectedItem.Text;
			
			// Customer
			this.tbCustomerName.Visible = false;
			this.lbCustomerNameReadOnly.Text = this.tbCustomerName.Text;
			this.rbIsFCPA.Visible = false;
			this.lbIsFCPAReadOnly.Text = this.rbIsFCPA.SelectedItem.Text;
			this.tbCustomerCountry.Visible = false;
			this.lbCustomerCountryReadOnly.Text = this.tbCustomerCountry.Text;
			this.tbVisitObjectives.Visible = false;
			this.lbVisitObjectivesReadOnly.Text = this.tbVisitObjectives.Text;
			this.tbPotentialRevenue.Visible = false;
			this.lbPotentialRevenueReadOnly.Text = this.tbPotentialRevenue.Text;
			this.ddlPotentialRevenueTime.Visible = false;
			this.lbPotentialRevenueTimeReadOnly.Text = this.ddlPotentialRevenueTime.SelectedItem.Text;
			this.ddlSaleStage.Visible = false;
			this.lbSaleStageReadOnly.Text = this.ddlSaleStage.SelectedItem.Text;

			this.rbOutStandingRFP.Visible = false;
			this.lbOutStandingRFPReadOnly.Text = this.rbOutStandingRFP.SelectedItem.Text;

			//this.Ctl_RFPDetails.Visible = false;
			//this.Lb_RFPDetails.Text = this.Ctl_RFPDetails.Text;


			this.RB_IsSensitiveIssue.Visible = false;
			this.lbIsSensitiveIssue.Text = this.RB_IsSensitiveIssue.SelectedItem.Text;
			this.tbSensitiveIssues.Visible = false;
			this.lbSeneitiveIssuesReadOnly.Text = this.tbSensitiveIssues.Text;

			this.RBL_KeyMessage.Visible = false;
			this.lbKeyMessage.Text = this.RBL_KeyMessage.SelectedItem.Text;
			this.tbKeyMessage.Visible = false;
			this.lbKeyMessageReadOnly.Text = this.tbKeyMessage.Text;

			this.tbCompanyProfile.Visible = false;
			this.lbCompanyProfileReadOnly.Text = this.tbCompanyProfile.Text;
			this.ddlAccountType.Visible = false;
			this.lbAccountTypeReadOnly.Text = this.ddlAccountType.SelectedItem.Text;
			this.tbProposalNo.Visible = false;
			this.lbProposalNoReadOnly.Text = this.tbProposalNo.Text;

		    tbRequestedDateToSpan.Visible = false;
			RequestedDateFromspan.Visible = false;

//			AlternativeDateFromspan.Visible = false;
//			AlternativeDateTospan.Visible = false;

			tbDatesRequiredFromSpan.Visible = false;
			tbDatesRequiredToSpan.Visible = false;


			// Business Purpose
			this.rbSalesContract.Visible = false;
			this.lbSalesContractReadOnly.Text = this.rbSalesContract.SelectedItem.Text;
			this.rbSalesContractSigned.Visible = false;
			this.lbSalesContractSignedReadOnly.Text = this.rbSalesContractSigned.SelectedItem.Text;
			this.tbNotSalesContractDescription.Visible = false;
			this.lbNotSalesContractDescriptionReadOnly.Text = this.tbNotSalesContractDescription.Text;
			this.rbActivityInTrip.Visible = false;
			this.lbActivityInTripReadOnly.Text = this.rbActivityInTrip.SelectedItem.Text;
			this.rbALInvitation.Visible = false;
			this.lbALInvitationReadOnly.Text = this.rbALInvitation.SelectedItem.Text;

//			this.Ctl_DetailedItinerary.Visible = false;
//			this.Lb_DetailedItinerary.Text = this.Ctl_DetailedItinerary.Text;

			this.tbTopic.Visible = false;
			this.lbTopicReadOnly.Text = this.tbTopic.Text;

			// Sales Team
			this.tbCustomerTeamHost.Visible = false;
			this.lbCustomerTeamHostReadOnly.Text = this.tbCustomerTeamHost.Text;
			this.tbCustomerOfficeTel.Visible = false;
			this.lbCustomerOfficeTelReadOnly.Text = this.tbCustomerOfficeTel.Text;
			this.tbCustomerFax.Visible = false;
			this.lbCustomerFaxReadOnly.Text = this.tbCustomerFax.Text;
			this.tbCustomerEmail.Visible = false;
			this.lbCustomerEmailReadOnly.Text = this.tbCustomerEmail.Text;
			this.ddlSalesBusinessUnit.Visible = false;
			this.lbSalesBusinessUnitReadOnly.Text = this.ddlSalesBusinessUnit.SelectedItem.Text;
			this.ddlRegion.Visible = false;
			this.lbRegionReadOnly.Text = this.ddlRegion.SelectedItem.Text;

			// LogisticalInfo
//			this.Dp_MeetingRoom.Visible = false;
//			if(this.Dp_MeetingRoom.SelectedItem!=null)
//			{
//				this.tx_MeetingRoom.Text = this.Dp_MeetingRoom.SelectedItem.Text;
//			}
			this.rbHotelRequired.Visible = false;
			this.lbHotelRequiredReadOnly.Text = this.rbHotelRequired.SelectedItem.Text;

			this.RBL_Meal.Visible = false;
			this.Lb_IsMealReservation.Text = this.RBL_Meal.SelectedItem.Text;
			this.Ctl_MealContent.Visible = false;
			this.tx_MealContent.Text = this.Ctl_MealContent.Text;
			this.Ctl_MealEachCost.Visible = false;
			this.LB_MealEachCost.Text = this.Ctl_MealEachCost.Text;

			this.Dp_PaymentForHotel.Visible = false;
			this.tx_PaymentForHotel.Text = this.Dp_PaymentForHotel.SelectedItem.Text;

			this.Ctl_LogisticComment.Visible = false;
			this.lbLogisticComment.Text = this.Ctl_LogisticComment.Text;

			//Fight Train info
			//this.Ctl_ArrivalFlightNo.Visible = false;
			//this.tx_ArrivalFightNo.Text = this.Ctl_ArrivalFlightNo.Text;
			//this.Ctl_ArrivalAirport.Visible = false;
			//this.tx_ArrivalAirport.Text = this.Ctl_ArrivalAirport.Text;
			//this.ArrivalTime.Visible = false;
			//this.tx_ArrivalTime.Text = this.ArrivalTime.Text;
			//this.Ctl_LeaveFlightNo.Visible = false;
			//this.tx_LeaveFightNo.Text = this.Ctl_LeaveFlightNo.Text;
			//this.Ctl_LeaveAirport.Visible = false;
			//this.tx_LeaveAirport.Text = this.Ctl_LeaveAirport.Text;
			//this.LeaveTime.Visible = false;
			//this.tx_LeaveTime.Text = this.LeaveTime.Text;

			this.tbDatesRequiredFrom.Visible = false;
			this.lbDatesRequiredFromReadOnly.Text = this.tbDatesRequiredFrom.Text;
			this.tbDatesRequiredTo.Visible = false;
			this.lbDatesRequiredToReadOnly.Text = this.tbDatesRequiredTo.Text;
			this.tbPriceRangeFrom.Visible = false;
			this.lbPriceRangeFromReadOnly.Text = this.tbPriceRangeFrom.Text;
			this.tbPriceRangeTo.Visible = false;
			this.lbPriceRangeToReadOnly.Text = this.tbPriceRangeTo.Text;
			this.rbTransportationRequired.Visible = false;
			this.lbTransportationRequiredReadOnly.Text = this.rbTransportationRequired.SelectedItem.Text;

			this.rbEntertainmentNeed.Visible = false;
			this.lbEntertainmentNeedReadOnly.Text = this.rbEntertainmentNeed.SelectedItem.Text;
			this.tbPreferEntertainment.Visible = false;
			this.lbPreferEntertainmentReadOnly.Text = this.tbPreferEntertainment.Text;
			this.tbEntertainmentPriceRangeFrom.Visible = false;
			this.lbEntertainmentPriceRangeFromReadOnly.Text = this.tbEntertainmentPriceRangeFrom.Text;
			this.tbEntertainmentPriceRangeTo.Visible = false;
			this.lbEntertainmentPriceRangeToReadOnly.Text = this.tbEntertainmentPriceRangeTo.Text;

			this.rbGiftNeed.Visible = false;
			this.lbGiftNeedReadOnly.Text = this.rbGiftNeed.SelectedItem.Text;
			this.tbPreferGift.Visible = false;
			this.lbPreferGiftReadOnly.Text = this.tbPreferGift.Text;
			this.tbGiftPriceRangeFrom.Visible = false;
			this.lbGiftPriceRangeFromReadOnly.Text = this.tbGiftPriceRangeFrom.Text;
			this.tbGiftPriceRangeTo.Visible = false;
			this.lbGiftPriceRangeToReadOnly.Text = this.tbGiftPriceRangeTo.Text;

			this.rbReceivedGift.Visible = false;
			this.lbReceivedGiftReadOnly.Text = this.rbReceivedGift.SelectedItem.Text;
			this.Ctl_GiftsDetails.Visible = false;
			this.Lb_GiftDetails.Text = this.Ctl_GiftsDetails.Text;

			this.rbInterpreterRequired.Visible = false;
			this.lbInterpreferRequiredReadOnly.Text = this.rbInterpreterRequired.SelectedItem.Text;
			this.rbSimultaneousConsecutive.Visible = false;
			this.lbSimultaneousConsecutiveReadOnly.Text = this.rbSimultaneousConsecutive.SelectedItem.Text;
			this.rbSpecialDialect.Visible = false;
			this.lbSpecialDialectReadOnly.Text = this.rbSpecialDialect.SelectedItem.Text;

			this.rbCateringService.Visible = false;
			this.lbCateringServiceReadOnly.Text = this.rbCateringService.SelectedItem.Text;
			this.tbCaterServiceExplain.Visible = false;
			this.lbCaterServiceExplainReadOnly.Text = this.tbCaterServiceExplain.Text;

			//ArrivalTimeSpan.Visible = false;
			//LeaveTimeSpan.Visible = false;

			HotelBookingImg.Visible = false;
			CompanyCarImg.Visible = false;
			LeaseCarImg.Visible = false;

			this.RB_IsTravelAgency.Visible = false;
			this.Lb_IsTravelAgency.Text = this.RB_IsTravelAgency.SelectedItem.Text;

			//this.Ctl_TravelAgency.Visible = false;
			//this.Lb_TravelAgency.Text = this.Ctl_TravelAgency.Text;

			this.rbCateringService.Visible = false;
			this.lbCateringServiceReadOnly.Text = this.rbCateringService.SelectedItem.Text;

			this.tbCaterServiceExplain.Visible = false;
			this.lbCaterServiceExplainReadOnly.Text = this.tbCaterServiceExplain.Text;

			// Payment Info
			this.ddlPayingFor.Visible = false;
			this.lbPayingForReadOnly.Text = this.ddlPayingFor.SelectedItem.Text;
			this.rbDirectToProvider.Visible = false;
			this.lbDirectToProviderReadOnly.Text = this.rbDirectToProvider.SelectedItem.Text;
			this.tbNotDirectReason.Visible = false;
			this.lbNotDirectReasonReadOnly.Text = this.tbNotDirectReason.Text;

			this.tbPaymentRemark.Visible = false;
			this.lbPaymentRemarkReadOnly.Text = this.tbPaymentRemark.Text;
			this.tbPerDiem.Visible = false;
			this.lbPerDiemReadOnly.Text = this.tbPerDiem.Text;

			this.tbEstimateTotalCost.Visible = false;
			this.lbEstimateTotalCostReadOnly.Text = this.tbEstimateTotalCost.Text;
			this.tbEstimateCostPerPerson.Visible = false;
			this.lbEstimateCostPerPersonReadOnly.Text = this.tbEstimateCostPerPerson.Text;
			this.Dp_ExpenseType.Visible = false;
			this.lbExpenseTypeReadOnly.Text = this.Dp_ExpenseType.SelectedItem.Text;

			//this.tbReason.Visible = false;
			//this.lbReasonReadOnly.Text = this.tbReason.Text;

			this.dgContractInfo.Columns[8].Visible =false;
			this.dgCustomerList.Columns[6].Visible = false;
			this.dgALAttendee.Columns[3].Visible = false;
			this.dgHotel.Columns[6].Visible = false;
			this.dgCompanyCar.Columns[4].Visible = false;
			this.dgLeaseCar.Columns[4].Visible = false;
			this.dgCostCenter.Columns[5].Visible = false;
		
		}
		#endregion

		private Nullables.NullableDateTime GetAppRequestDate(int appID)
		{
			BEGDC.CC.BL.Common.Query.IQuery queryService= AppContainer.Instance[ServiceConst.QueryService] as BEGDC.CC.BL.Common.Query.IQuery;
			return queryService.GetAppRequestDate(appID);
		}

		#region BuildApplication
		public void BuildApplication(ref Application app, ref CustomerInfo customer, ref BusinessPurpose business, 
			ref Topic topic, ref SalesTeamInfo salesTeam, ref LogisticalInfo logist, ref PaymentInfo payment, 
			ref IList customerAttendee, ref IList alAttendee, ref IList site, ref IList cost, ref IList contract, ref DataTable HotelTable, ref DataTable CompanyCarTable, ref DataTable LeaseCarTable)
		{
			IUtility utiService = AppContainer.Instance[ServiceConst.UtilityService] as IUtility;
			IQuery query = AppContainer.Instance[ServiceConst.QueryService] as IQuery;

			if (app.Id>0)
			{
				if (app.RequestDate==Nullables.NullableDateTime.Default)
				{
					Nullables.NullableDateTime date=GetAppRequestDate(app.Id);

					if (date !=Nullables.NullableDateTime.Default)
					{
						app.RequestDate =date;
					}
				}		
			}

			//app.Id = this.AppID;
			app.EZVisitReqNo = string.Empty;
			app.LGDNo = string.Empty;
			app.ApplicationType = WorkflowTypes.ECS;
			app.RequesterOfficeTel = this.tbRequestOfficeTel.Text.Trim();
			app.RequesterMobile = this.tbRequestorMobile.Text.Trim();

			bool IsECS = this.rbECS.SelectedValue == "1";
			app.IsSSME = IsECS;
			if(IsECS)
			{
				//DicItem CostCenterItem = new DicItem();
				//CostCenterItem.Id = Convert.ToInt32();
				//app.CostCenterCode = CostCenterItem;
				app.CostCenterCode = utiService.GetDicItem(Convert.ToInt32(this.Dp_CostCenter.SelectedValue));
				app.DepartmentName = query.GetDepartmentByCostCenter(this.Dp_CostCenter.SelectedItem.Text);
			}
			else
			{
				//DicItem DepartmentItem = new DicItem();
				//DepartmentItem.Id = Convert.ToInt32(this.Dp_Department.SelectedValue);
				//app.DepartmentType = DepartmentItem;
				app.DepartmentType = utiService.GetDicItem(Convert.ToInt32(this.Dp_Department.SelectedValue));
				app.DepartmentName = query.GetDepartmentByCode(this.Dp_Department.SelectedItem.Text);
			}

			if(this.ddlLegalEntity.SelectedItem!=null)
			{
				app.LegalEntity = new LegalEntity();
				app.LegalEntity.Id = Convert.ToInt32(this.ddlLegalEntity.SelectedValue);
			}
			
			//IQuery query = AppContainer.Instance[ServiceConst.QueryService] as IQuery;
			//BEGDC.CC.Entity.Department dept = query.GetDepartmentByCode(this.Dp_Department.SelectedValue.ToString());

			//if((dept!=null && (dept.DepartmentType.DicItemKey == BEGDC.CC.BL.Common.SysDicItem.DepartmentType.CAT)) || (this.Dp_Department.SelectedValue.ToString() == "OTH"))
			//{
				//app.Account = string.Empty;
			//}

			app.IsReviewedGuideline = this.rbReviewGuideLine.SelectedValue == "1";
			app.OtherSite = this.tbOtherLocation.Text.Trim();
			app.RequesterNameEN = this.tbRequestorName.Text.Trim();
			if(this.tbRequestedDateFrom.Text!="")
			{
				app.RequestedDateFrom = Convert.ToDateTime(this.tbRequestedDateFrom.Text);
			}
			if(this.tbRequestedDateTo.Text!="")
			{
				app.RequestedDateTo = Convert.ToDateTime(this.tbRequestedDateTo.Text);
			}
//			if(this.tbAlternateDateFrom.Text != string.Empty)
//			{
//				app.AlternateDateFrom = Convert.ToDateTime(this.tbAlternateDateFrom.Text);
//			}
//			if(this.tbAlternateDateTo.Text != string.Empty)
//			{
//				app.AlternateDateTo = Convert.ToDateTime(this.tbAlternateDateTo.Text);
//			}

			IUser userService = AppContainer.Instance[ServiceConst.UserService] as IUser;
			app.RequesterNo = userService.GetUser(app.RequesterNameEN);
			
			// Apply for someone else
			bool applyForSomeElse = this.rbSomeoneElse.SelectedValue == "1";
			app.ApplyForSomeoneElse = applyForSomeElse;
			if(applyForSomeElse)
			{
				//app.DepartmentName = this.GetUser(this.SearchStaff.EmployeeName).Department;

				app.SomeoneElseHRID = this.Ctl_HRID.Text.Trim();
				app.SomeoneElseNo = this.GetUserById(this.SearchStaff.EmployeeID);
				app.SomeoneElseNameEN = this.SearchStaff.EmployeeName;
				app.SomeoneElseTel = this.tbSomeoneTel.Text.Trim();
				app.SomeoneElseMobil = this.Ctl_SomeoneMobil.Text.Trim();
				app.SomeoneElseEmail = this.tbSomeoneEmail.Text.Trim();
			}
			else
			{
				//app.DepartmentName = this.GetUser(app.RequesterNameEN).Department;
				app.SomeoneElseHRID = string.Empty;
				app.SomeoneElseNo = null;
				app.SomeoneElseNameEN = string.Empty;
				app.SomeoneElseTel = string.Empty;
				app.SomeoneElseMobil = string.Empty;
				app.SomeoneElseEmail = string.Empty;
			}

			// Customer Info
			customer.Id = this.CustomerID;
			customer.Company = this.tbCustomerName.Text.Trim();
			customer.IsFCPA = this.rbIsFCPA.SelectedValue == "1";
			customer.Country = this.tbCustomerCountry.Text.Trim();
			customer.VisitObjective = this.tbVisitObjectives.Text.Trim();

			// Build When it is Covered Person Application*************************************************************
			if(this.isCoveredPerson)
			{
				app.BUHeadApproved = this.rbBUHeadApproval.SelectedValue == "1";
				if(WebUtility.IsNumber(this.tbPotentialRevenue.Text))
				{
					customer.DecryptedRevenuePotential = Convert.ToDecimal(this.tbPotentialRevenue.Text);
				}
				if(this.ddlPotentialRevenueTime.SelectedItem!=null)
				{
					customer.PotentialRevenueTimeframe = Convert.ToInt32(this.ddlPotentialRevenueTime.SelectedValue);
				}
				if(this.ddlSaleStage.SelectedItem!=null)
				{
					customer.SalesStage = Convert.ToInt32(this.ddlSaleStage.SelectedValue);
				}

				bool ISRFP = this.rbOutStandingRFP.SelectedValue == "1";
				customer.IsInRFP = ISRFP;
//				if(ISRFP)
//				{
//					customer.RFPDetail = this.Ctl_RFPDetails.Text;
//				}
//				else
//				{
//					customer.RFPDetail = string.Empty;
//				}

				bool ISSensiveIssue = this.RB_IsSensitiveIssue.SelectedValue == "1";
				customer.IsSensitiveIssue = ISSensiveIssue;
				if(ISSensiveIssue)
				{
					customer.IsThereSensitiveIssue = this.tbSensitiveIssues.Text;
				}
				else
				{
					customer.IsThereSensitiveIssue = string.Empty;
				}

				bool ISKEYMessage = this.RB_IsSensitiveIssue.SelectedValue == "1";
				customer.IsKeyMessage = ISKEYMessage;
				if(ISKEYMessage)
				{
					customer.IsThereKeyMessage = this.tbKeyMessage.Text;
				}
				else
				{
					customer.IsThereKeyMessage = string.Empty;
				}
				customer.ProposalNo = this.tbProposalNo.Text.Trim();
			}
			//*******************************************************************************************

			customer.CompanyProfile = this.tbCompanyProfile.Text.Trim();
			customer.AccountType = new DicItem();
			if(this.ddlAccountType.SelectedItem!=null)
			{
				customer.AccountType.Id = Convert.ToInt32(this.ddlAccountType.SelectedValue);
			}

			// BusinessPurpose
			business.Id = this.BusinessID;
			bool ISContract = this.rbSalesContract.SelectedValue == "1";
			business.IsInSalesContract = ISContract;
			if(ISContract)
			{
				bool ISSIGNED = this.rbSalesContractSigned.SelectedValue == "1";
				business.IsContractSigned = ISSIGNED;
				if(ISSIGNED)
				{
					// Contract Info
					DataTable contracttable = (DataTable)this.dgContractInfo.DataSource;
					if(contracttable != null && contracttable.Rows.Count > 0)
					{
						for(int i=0;i<contracttable.Rows.Count;i++)
						{
							ContractInfo ci = new ContractInfo();
							ci.DateOfContract = Convert.ToDateTime(contracttable.Rows[i]["DateOfContract"]);
							ci.ContractNo = contracttable.Rows[i]["ContractNo"].ToString();
							ci.ProducstSold = contracttable.Rows[i]["ProducstSold"].ToString();
							ci.VisitPurposeInContract = contracttable.Rows[i]["VisitPurposeInContract"].ToString();
							ci.Quotas = Convert.ToInt32(contracttable.Rows[i]["Quotas"]);
							ci.UnitPrice = Convert.ToDecimal(contracttable.Rows[i]["UnitPrice"]);
							ci.Budget = Convert.ToDecimal(contracttable.Rows[i]["Budget"]);
			
							contract.Add(ci);
						}
					}
				}
			}
			else
			{
				business.IsContractSigned = false;
				business.Opportunities = this.tbNotSalesContractDescription.Text;
				business.Itinerary = this.tbNotSalesContractDescription.Text;
			}
			//business.IsContractSigned = this.rbSalesContractSigned.SelectedValue == "1";

//			business.DateOfContract = Convert.ToDateTime(this.tbContractDate.Text);
//			business.ContractNo = this.tbContractNo.Text.Trim();
//			business.ProductsSold = this.tbContractProducts.Text.Trim();
//			business.VisitPurposeInContract = this.tbContractTripPurpose.Text.Trim();
//			business.Quotas = Convert.ToInt32(this.tbContractQuotas.Text);
//			business.UnitPrice = Convert.ToDecimal(this.tbUnitPrice.Text);
//			business.Opportunities = this.tbNotSalesContractDescription.Text.Trim();

			bool ISACTIVITY = this.rbActivityInTrip.SelectedValue == "1";
			business.RecreationalActivity = ISACTIVITY;
//			if(ISACTIVITY)
//			{
//				business.Itinerary = this.Ctl_DetailedItinerary.Text;
//			}
//			else
//			{
//				business.Itinerary = string.Empty;
//			}
			//Build when it is covered Person Application*****************************************************
			if(this.isCoveredPerson)
			{
				business.IsNeedInvitationLetter = this.rbALInvitation.SelectedValue == "1";
			}
			//*************************************************************************************

			topic.Id = this.TopicID;
			topic.TopicName = this.tbTopic.Text.Trim();

			// SalesTeam
			salesTeam.Id = this.SalesTeamID;
			salesTeam.HostNameEN = this.tbCustomerTeamHost.Text.Trim();
			salesTeam.OfficeTel = this.tbCustomerOfficeTel.Text.Trim();
			salesTeam.OfficeFax = this.tbCustomerFax.Text.Trim();
			salesTeam.Email = this.tbCustomerEmail.Text.Trim();
			if(this.ddlSalesBusinessUnit.SelectedItem!=null)
			{
				salesTeam.SalesBusinessUnit = this.ddlSalesBusinessUnit.SelectedValue;
			}
			if(this.ddlRegion.SelectedItem!=null)
			{
				salesTeam.Region = this.ddlRegion.SelectedValue;
			}

			// LogisticalInfo
			logist.Id = this.LogistID;
			logist.IsNeedHotel = this.rbHotelRequired.SelectedValue == "1";

			// Build when it is covered person application********************************************************
			if(this.isCoveredPerson)
			{
				if(this.tbDatesRequiredFrom.Text!="")
				{
					logist.DateRequiredFrom = Convert.ToDateTime(this.tbDatesRequiredFrom.Text);
				}
				if(this.tbDatesRequiredTo.Text!="")
				{
					logist.DateRequiredTo = Convert.ToDateTime(this.tbDatesRequiredTo.Text);
				}
				bool ISMEAL = this.RBL_Meal.SelectedValue == "1";
				logist.IsMealReservation = ISMEAL;
				if(ISMEAL)
				{
					logist.MealReservation = this.Ctl_MealContent.Text;
					if(WebUtility.IsNumber(this.Ctl_MealEachCost.Text))
					{
						logist.AverageMealCost = Convert.ToDecimal(this.Ctl_MealEachCost.Text);
					}
				}
				else
				{
					logist.MealReservation = string.Empty;
					logist.AverageMealCost = 0;
				}
			}
			//***************************************************************************************


			if(WebUtility.IsNumber(this.tbPriceRangeFrom.Text))
				logist.DecryptedPriceFrom = Convert.ToDecimal(this.tbPriceRangeFrom.Text);
			if(WebUtility.IsNumber(this.tbPriceRangeTo.Text))
				logist.DecryptedPriceTo = Convert.ToDecimal(this.tbPriceRangeTo.Text);
			logist.IsNeedGroundTransportation = this.rbTransportationRequired.SelectedValue == "1";

			//IUtility utiService = AppContainer.Instance[ServiceConst.UtilityService] as IUtility;
			//logist.MeetingRoom = utiService.GetDicItem(Convert.ToInt32(this.Dp_MeetingRoom.SelectedItem.Value));
			logist.PaymentForHotel = utiService.GetDicItem(Convert.ToInt32(this.Dp_PaymentForHotel.SelectedItem.Value));
			logist.Comment = this.Ctl_LogisticComment.Text;

			// Flight Info
			//logist.ArrivalFlightNo = this.Ctl_ArrivalFlightNo.Text;
			//logist.DepartureFlightNo = this.Ctl_LeaveFlightNo.Text;
            
			//logist.ArrivalAirport = this.Ctl_ArrivalAirport.Text;
			//logist.DepartureAirport = this.Ctl_LeaveAirport.Text;

//			string ArrivalTime = this.ArrivalTime.Text;
//			if(ArrivalTime!="")
//			{
//				logist.ArrivalTime = Nullables.NullableDateTime.Parse(ArrivalTime); 
//			}
//			string DepartureTime = this.LeaveTime.Text;
//			if(DepartureTime!="")
//			{
//				logist.DepartureTime = Nullables.NullableDateTime.Parse(DepartureTime); 
//			}

			bool ISPREFERENCE = this.rbEntertainmentNeed.SelectedValue == "1";
			logist.IsNeedEntertainment = ISPREFERENCE;
			if(ISPREFERENCE)
			{
				logist.EntertainmentPreference = this.tbPreferEntertainment.Text.Trim();
			}
			else
			{
				logist.EntertainmentPreference = string.Empty;
			}

			bool ISGIFT = this.rbGiftNeed.SelectedValue == "1";
			logist.IsNeedGift = ISGIFT;
			if(ISGIFT)
			{
				logist.GiftDetails = this.tbPreferGift.Text;
			}
			else
			{
				logist.GiftDetails = string.Empty;
			}

			if(WebUtility.IsNumber(this.tbEntertainmentPriceRangeFrom.Text))
			{
				logist.DecryptedEntertainmentPriceFrom = Convert.ToDecimal(this.tbEntertainmentPriceRangeFrom.Text);
			}
			if(WebUtility.IsNumber(this.tbEntertainmentPriceRangeTo.Text))
			{
				logist.DecryptedEntertainmentPriceTo = Convert.ToDecimal(this.tbEntertainmentPriceRangeTo.Text);
			}
			
			if(WebUtility.IsNumber(this.tbGiftPriceRangeFrom.Text))
			{
				logist.DecryptedGiftPriceFrom = Convert.ToDecimal(this.tbGiftPriceRangeFrom.Text);
			}
			if(WebUtility.IsNumber(this.tbGiftPriceRangeTo.Text))
			{
				logist.DecryptedGiftPriceTo = Convert.ToDecimal(this.tbGiftPriceRangeTo.Text);
			}

			bool ISRECEIVEDGIFT = this.rbReceivedGift.SelectedValue == "1";
			logist.IsReceivedALGiftBefore = ISRECEIVEDGIFT;
			if(ISRECEIVEDGIFT)
			{
				logist.ReceivedGiftDetails = this.Ctl_GiftsDetails.Text.Trim();
			}
			else
			{
				logist.ReceivedGiftDetails = string.Empty;
			}
			logist.IsNeedInterpreter = this.rbInterpreterRequired.SelectedValue == "1";
			logist.InterpretionType = Convert.ToInt32(this.rbSimultaneousConsecutive.SelectedValue);
			logist.SpecialDialect = this.rbSpecialDialect.SelectedValue;

			
			bool ISAGENCY = this.RB_IsTravelAgency.SelectedValue == "1";
			logist.IsNeedTravelAgency = ISAGENCY;
//			if(ISAGENCY)
//			{
//				logist.TravelAgency = this.Ctl_TravelAgency.Text.Trim();
//			}
//			else
//			{
//				logist.TravelAgency = string.Empty;
//			}

			bool ISCATERING = this.rbCateringService.SelectedValue == "1";
			logist.IsNeedCatering = ISCATERING;
			if(ISCATERING)
			{
				logist.CateringDescription = this.tbCaterServiceExplain.Text.Trim();
			}
			else
			{
				logist.CateringDescription = string.Empty;
			}

			// Payment Info
			payment.Id = this.PaymentID;

			// Build when it is covered person application***************************************************
			if(this.isCoveredPerson)
			{
				payment.Payer = Convert.ToInt32(this.ddlPayingFor.SelectedValue);
				payment.IsPayServiceProvider = this.rbDirectToProvider.SelectedValue == "1";
				payment.NotDirectPayReasons = this.tbNotDirectReason.Text.Trim();
			}
			//************************************************************************************
            payment.CustomerPerdiem = this.tbPerDiem.Text.Trim();
			payment.Comments = this.tbPaymentRemark.Text.Trim();

			if(WebUtility.IsNumber(this.tbEstimateTotalCost.Text))
			{
				payment.DecryptedEstimatedCustomerTotalCost = Convert.ToDecimal(this.tbEstimateTotalCost.Text);
			}
			if(WebUtility.IsNumber(this.tbEstimateCostPerPerson.Text))
			{
				payment.DecryptedEstimateCustomerdIndividualCost = Convert.ToDecimal(this.tbEstimateCostPerPerson.Text);
			}
			payment.ExpenseType = utiService.GetDicItem(Convert.ToInt32(this.Dp_ExpenseType.SelectedValue));

			// site info
			for(int i=0;i<this.cblPreferredLocation.Items.Count;i++)
			{
				if(cblPreferredLocation.Items[i].Selected)
				{
					AppVisitingSite appSite = new AppVisitingSite();
					appSite.Site = new DicItem();
					appSite.Site.Id = Convert.ToInt32(cblPreferredLocation.Items[i].Value);

					site.Add(appSite);
				}
			}

			// Customer Attendee Info
//			DataTable table = (DataTable)this.dgCustomerList.DataSource;
//			if(table != null && table.Rows.Count > 0)
//			{
//				for(int i=0;i<table.Rows.Count;i++)
//				{
//					CustomerAttendee cus = new CustomerAttendee();
//					cus.NameEN = table.Rows[i]["Name"].ToString();
//					cus.Title = table.Rows[i]["Title"].ToString();
//					cus.Company = table.Rows[i]["Company"].ToString();			
//					cus.NameCN = table.Rows[i]["NameCN"].ToString();
//					cus.TitleEN = table.Rows[i]["TitleEN"].ToString();
//					cus.CompanyEN = table.Rows[i]["CompanyEN"].ToString();				
//					cus.Responsibility = new DicItem();
//					cus.Responsibility.Id =	Convert.ToInt32(table.Rows[i]["ResponsibilityID"]);
//					cus.Affects = new DicItem();
//					cus.Affects.Id = Convert.ToInt32(table.Rows[i]["AffectsID"]);
//					cus.IsAttended = true;
//
//					cus.Remark = table.Rows[i]["Remark"].ToString();
//					cus.IsExisted = Convert.ToInt32(table.Rows[i]["IsExisted"]);
//
//					customerAttendee.Add(cus);
//				}
//			}
			DataTable table = (DataTable)this.dgCustomerList.DataSource;
			if(table != null && table.Rows.Count > 0)
			{
				for(int i=0;i<table.Rows.Count;i++)
				{
					CustomerAttendee cus = new CustomerAttendee();
					cus.NameEN = table.Rows[i]["Name"].ToString();
					cus.Title = table.Rows[i]["Title"].ToString();
					cus.Company = table.Rows[i]["Company"].ToString();		
					cus.NameCN = table.Rows[i]["NameCN"].ToString();
					cus.TitleEN = table.Rows[i]["TitleEN"].ToString();
					cus.CompanyEN = table.Rows[i]["CompanyEN"].ToString();		
					cus.Responsibility = new DicItem();
					cus.Responsibility.Id =	Convert.ToInt32(table.Rows[i]["ResponsibilityID"]);
					cus.Affects = new DicItem();
					cus.Affects.Id = Convert.ToInt32(table.Rows[i]["AffectsID"]);
					cus.IsAttended = true;

					cus.Remark = table.Rows[i]["Remark"].ToString();
					cus.IsExisted = Convert.ToInt32(table.Rows[i]["IsExisted"]);

					customerAttendee.Add(cus);
				}
			}



			if(this.dgCustomerList.Items.Count>0)
			{
				customer.NumberOfPerson = this.dgCustomerList.Items.Count.ToString(); 
			}

			// AL Attendee Info
			table = (DataTable)this.dgALAttendee.DataSource;
			if(table != null && table.Rows.Count > 0)
			{
				for(int i=0;i<table.Rows.Count;i++)
				{
					ALAttendee al = new ALAttendee();
					al.EmployeeId = new Employee();
					al.EmployeeId.Id = table.Rows[i]["EmployeeId"].ToString();
					al.Title = table.Rows[i]["Title"].ToString();
			
					alAttendee.Add(al);
				}
			}

			// NEW UPDATE JOVI
			HotelTable = (DataTable)this.dgHotel.DataSource;
			CompanyCarTable = (DataTable)this.dgCompanyCar.DataSource;
			LeaseCarTable = (DataTable)this.dgLeaseCar.DataSource;

			// Cost Center Info
			table = (DataTable)this.dgCostCenter.DataSource;
			if(table != null && table.Rows.Count > 0)
			{
				for(int i=0;i<table.Rows.Count;i++)
				{
					CostCenterRelatedCost co = new CostCenterRelatedCost();
					co.CostCenterCode = table.Rows[i]["CostCenterCode"].ToString();
					co.DecryptedCost = Convert.ToDecimal(table.Rows[i]["Cost"]);
					co.CostType = CostType.Budget;
			
					cost.Add(co);
				}
			}
		}
		#endregion

		#region ItemDataBound

		private void dgCustomerList_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
			{
				ImageButton Btn_Edit = (ImageButton) e.Item.Cells[5].FindControl("Btn_Edit");
				string ItemId = e.Item.Cells[0].Text.ToString();
				Btn_Edit.Attributes.Add("onclick", "OpenCustomerPane('"+ItemId+"');");
				Btn_Edit.Attributes.Add("check", "false");

				ImageButton ld = (ImageButton)e.Item.Cells[6].FindControl("Btn_Delete");
				if(ld != null)
				{
					ld.Attributes.Add("onclick","On_Submit();");
					ld.Attributes.Add("check", "false");
				}

				string IsExisted = e.Item.Cells[7].Text.ToString();
				if(IsExisted==BEGDC.CC.BL.Common.CISFlag.NotExisted)
				{
					System.Web.UI.WebControls.Image WarningImg = (System.Web.UI.WebControls.Image) e.Item.Cells[8].FindControl("CISWarning");
					WarningImg.Visible = true;
				}

				LinkButton lb = (LinkButton)e.Item.Cells[10].FindControl("lb_AttendeeCount");
				if(lb != null)
				{
					lb.Text = e.Item.Cells[9].Text;
					Session["Attendee_CustomerName"] = e.Item.Cells[1].Text;
					Session["Attendee_CustomerCompany"] = e.Item.Cells[2].Text;
					lb.Attributes.Add("onclick","javascript:OpenApplicationPane();");
				}
			}
		}
		
		private void dgALAttendee_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
			{
				ImageButton Btn_Edit = (ImageButton) e.Item.Cells[3].FindControl("Btn_ALEdit");
				string ItemId = e.Item.Cells[0].Text.ToString();
				Btn_Edit.Attributes.Add("onclick", "OpenALAttendeePane('"+ItemId+"');");
				Btn_Edit.Attributes.Add("check", "false");

				ImageButton ld = (ImageButton)e.Item.Cells[3].FindControl("Btn_ALDelete");
				if(ld != null)
				{
					ld.Attributes.Add("onclick","On_Submit();");
					ld.Attributes.Add("check", "false");
				}
			}
		}

		
		private void dgCostCenter_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
			{
				ImageButton Btn_Edit = (ImageButton) e.Item.Cells[3].FindControl("Btn_CostEdit");
				string ItemId = e.Item.Cells[0].Text.ToString();
				Btn_Edit.Attributes.Add("onclick", "OpenCostCenterPane('"+ItemId+"');");
				Btn_Edit.Attributes.Add("check", "false");

				ImageButton ld = (ImageButton)e.Item.Cells[3].FindControl("Btn_CostDelete");
				if(ld != null)
				{
					ld.Attributes.Add("onclick","On_Submit();");
					ld.Attributes.Add("check", "false");
				}
			}
		}

		private void dgContractInfo_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
			{
				ImageButton Btn_Edit = (ImageButton) e.Item.Cells[8].FindControl("Btn_ContractEdit");
				string ItemId = e.Item.Cells[0].Text.ToString();
				Btn_Edit.Attributes.Add("onclick", "OpenContractPane('"+ItemId+"');");
				
				ImageButton ld = (ImageButton)e.Item.Cells[8].FindControl("Btn_ContractDelete");
				if(ld != null)
				{
					ld.Attributes.Add("onclick","On_Submit();");
					ld.Attributes.Add("check", "false");
				}
			}
		}

		#endregion

		#region Delete Command
		private void dgContractInfo_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			try
			{
				if(Request.Form["cbDel"] == null || Request.Form["cbDel"] == "1")
				{
					return;
				}

				int rowid = Convert.ToInt32(e.Item.Cells[0].Text);
			
				DataTable contractInfo = (DataTable)Session[SessionFlag.ContractInfo];
				DataRow contractRow = contractInfo.Rows[rowid-1];
				contractInfo.Rows.Remove(contractRow);
				this.BindContractInfo();
			}
			catch
			{	
			}
		}

		private void dgCustomerList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			try
			{
				if(Request.Form["cbDel"] == null || Request.Form["cbDel"] == "1")
				{
					return;
				}

				int rowid = Convert.ToInt32(e.Item.Cells[0].Text);
			
				DataTable contractInfo = (DataTable)Session[SessionFlag.CustomerSessionEZ];
				DataRow contractRow = contractInfo.Rows[rowid-1];
				contractInfo.Rows.Remove(contractRow);
				this.BindCustomerAttendee();
			}
			catch
			{	
			}
		}

		private void dgALAttendee_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			try
			{
				if(Request.Form["cbDel"] == null || Request.Form["cbDel"] == "1")
				{
					return;
				}

				int rowid = Convert.ToInt32(e.Item.Cells[0].Text);
			
				DataTable contractInfo = (DataTable)Session[SessionFlag.AccompanySessionEZ];
				DataRow contractRow = contractInfo.Rows[rowid-1];
				contractInfo.Rows.Remove(contractRow);
				this.BindALAttendee();
			}
			catch
			{	
			}
		}

		private void dgCostCenter_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			try
			{
				if(Request.Form["cbDel"] == null || Request.Form["cbDel"] == "1")
				{
					return;
				}

				int rowid = Convert.ToInt32(e.Item.Cells[0].Text);
			
				DataTable contractInfo = (DataTable)Session[SessionFlag.CostCenter];
				DataRow contractRow = contractInfo.Rows[rowid-1];
				contractInfo.Rows.Remove(contractRow);
				this.BindCostCenter();
			}
			catch
			{	
			}
		}
		#endregion

		#region Select Change
		private void Contract_Select(object sender, System.EventArgs e)
		{
			if(this.rbSalesContractSigned.SelectedValue == "1")
			{
				this.Table_Contract.Visible = true;
			}
			else
			{
				this.Table_Contract.Visible = false;
			}
		}

		private void Select_Catering(object sender, System.EventArgs e)
		{
			if(this.rbCateringService.SelectedValue == "1")
			{
				this.TR_Catering.Visible = true;
			}
			else
			{
				this.TR_Catering.Visible = false;
			}
		}

		private void rbSomeoneElse_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.litScript.Visible = true;
			if(this.rbSomeoneElse.SelectedValue == "1")
				this.litScript.Text = "<script>showpart2(1);</script>";
			else
				this.litScript.Text = "<script>showpart2(0);</script>";
		}
		#endregion

		#region CheckCustomer
		private bool CheckCISCustomer()
		{
			if(this.dgCustomerList.Items.Count==0) return false;
			foreach(DataGridItem row in this.dgCustomerList.Items)
			{
				string IsExisted = row.Cells[7].Text.ToString();
				if(IsExisted==BEGDC.CC.BL.Common.CISFlag.NotExisted)
				{
					return true;
				}
			}
			return false;
		}
		#endregion

		#region CATBranch_SelectChange
//		private void CATBranch_SelectChange(object sender, System.EventArgs e)
//		{
//			IQuery query = AppContainer.Instance[ServiceConst.QueryService] as IQuery;
//			BEGDC.CC.Entity.Department dept = query.GetDepartmentByCode(this.Dp_Department.SelectedValue);
//			
//			if((dept!=null && (dept.DepartmentType.DicItemKey == BEGDC.CC.BL.Common.SysDicItem.DepartmentType.CAT)) || (this.Dp_Department.SelectedValue.ToString() == "OTH"))
//			{
//				this.TR_Account.Visible = false;
//			}
//			else
//			{
//				this.TR_Account.Visible = true;
//			}
//		}
		#endregion

		#region DisableEditECS
		public void DisableEditECS()
		{
			this.rbECS.Enabled = false;
			this.Dp_Department.Enabled = false;
			this.Dp_CostCenter.Enabled = false;
		}
		#endregion

		#region DataGrid DataBound
		// Company Car DataBound
		private void EZCompanyCarDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
			{
				System.Web.UI.WebControls.ImageButton Btn_Edit = (System.Web.UI.WebControls.ImageButton) e.Item.Cells[4].FindControl("Btn_AlcatelCar_Edit");
				//string ItemId = e.Item.Cells[0].Text.ToString();
				Btn_Edit.Attributes.Add("onclick", "OpenCompanyCarPane("+e.Item.ItemIndex+",'Edit');");

				ImageButton ld = (ImageButton)e.Item.Cells[4].FindControl("Btn_CompanyCarDelete");
				if(ld != null)
				{
					ld.Attributes.Add("onclick","On_Submit();");
					ld.Attributes.Add("check", "false");
				}
			}
		}

		private void EZCompanyCarDeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			try
			{
				if(Request.Form["cbDel"] == null || Request.Form["cbDel"] == "1")
				{
					return;
				}

				int rowid = e.Item.ItemIndex;
			
				DataTable CompanyCarDataTable = (DataTable)Session[SessionFlag.CompanyCarSessionEZ];
				DataRow CompanyCarRow = CompanyCarDataTable.Rows[rowid];
				CompanyCarDataTable.Rows.Remove(CompanyCarRow);

				Session[SessionFlag.CompanyCarSessionEZ] = CompanyCarDataTable;
				object SessCompanyBooking = Session[SessionFlag.CompanyCarSessionEZ];
				if(SessCompanyBooking!=null)
				{
					CompanyCarDataTable = (DataTable)SessCompanyBooking;
					this.dgCompanyCar.DataSource = CompanyCarDataTable;
					this.dgCompanyCar.DataBind();
				}
			}
			catch
			{	
			}
		}

		//Lease Car DataBound

		
		private void EZLeaseCarDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
			{
				System.Web.UI.WebControls.ImageButton Btn_Edit = (System.Web.UI.WebControls.ImageButton) e.Item.Cells[4].FindControl("Btn_LeaseCar_Edit");
				//string ItemId = e.Item.Cells[0].Text.ToString();
				Btn_Edit.Attributes.Add("onclick", "OpenLeaseCarPane("+e.Item.ItemIndex+",'Edit');");

				ImageButton ld = (ImageButton)e.Item.Cells[4].FindControl("Btn_LeaseCarDelete");
				if(ld != null)
				{
					ld.Attributes.Add("onclick","On_Submit();");
					ld.Attributes.Add("check", "false");
				}
			}
		}

		private void EZLeaseCarDeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			try
			{
				if(Request.Form["cbDel"] == null || Request.Form["cbDel"] == "1")
				{
					return;
				}

				int rowid = e.Item.ItemIndex;
			
				DataTable LeaseCarDataTable = (DataTable)Session[SessionFlag.LeaseCarSessionEZ];
				DataRow LeaseCarRow = LeaseCarDataTable.Rows[rowid];
				LeaseCarDataTable.Rows.Remove(LeaseCarRow);

				Session[SessionFlag.LeaseCarSessionEZ] = LeaseCarDataTable;
				object SessLeaseBooking = Session[SessionFlag.LeaseCarSessionEZ];
				if(SessLeaseBooking!=null)
				{
					LeaseCarDataTable = (DataTable)SessLeaseBooking;
					this.dgLeaseCar.DataSource = LeaseCarDataTable;
					this.dgLeaseCar.DataBind();
				}
			}
			catch
			{	
			}
		}
		
		private void EZHotelDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
			{
				System.Web.UI.WebControls.ImageButton Btn_Edit = (System.Web.UI.WebControls.ImageButton) e.Item.Cells[6].FindControl("Btn_Hotel_Edit");
				//string ItemId = e.Item.Cells[0].Text.ToString();
				Btn_Edit.Attributes.Add("onclick", "OpenHotelBookingPane("+e.Item.ItemIndex+",'Edit');");

				ImageButton ld = (ImageButton)e.Item.Cells[3].FindControl("Btn_HotelDelete");
				if(ld != null)
				{
					ld.Attributes.Add("onclick","On_Submit();");
					ld.Attributes.Add("check", "false");
				}
			}
		}

		private void EZHotelList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			try
			{
				if(Request.Form["cbDel"] == null || Request.Form["cbDel"] == "1")
				{
					return;
				}

				int rowid = e.Item.ItemIndex;
			
				DataTable HotelDataTable = (DataTable)Session[SessionFlag.HotelSessionEZ];
				DataRow HotelRow = HotelDataTable.Rows[rowid];
				HotelDataTable.Rows.Remove(HotelRow);

				Session[SessionFlag.HotelSessionEZ] = HotelDataTable;
				object SessHotelBooking = Session[SessionFlag.HotelSessionEZ];
				if(SessHotelBooking!=null)
				{
					HotelDataTable = (DataTable)SessHotelBooking;
					this.dgHotel.DataSource = HotelDataTable;
					this.dgHotel.DataBind();
				}
			}
			catch
			{	
			}
		}
		#endregion

		#region Calculation Methods
		private string CalculateSum()
		{
			decimal sum = 0;
			DataTable table = (DataTable)this.dgContractInfo.DataSource;
			if(table != null)
			{
				for(int i=0; i<table.Rows.Count; i++)
				{
					sum += Convert.ToDecimal(table.Rows[i]["Budget"]);
				}
			}

			return sum.ToString("0.00");
		}

		private string CalculateCostSum()
		{
			decimal sum = 0;
			DataTable table = (DataTable)this.dgCostCenter.DataSource;
			if(table != null)
			{
				for(int i=0; i<table.Rows.Count; i++)
				{
					sum += Convert.ToDecimal(table.Rows[i]["Cost"]);
				}
			}

			return sum.ToString("0.00");
		}

		public void SetCloseControlVisiable()
		{
			this.closectl1.Visible = true;
		}

		public void SaveCloseControl()
		{
			this.closectl1.SaveApplication();
		}

		public void SubmitCloseControl()
		{
			this.closectl1.SubmitApplication();
		}

		public void BindCloseControl()
		{
			this.closectl1.BindApplication();
			this.closectl1.BindCostCenter();
		}

		public void SetCloseControlEnable()
		{
			this.closectl1.SetEnableStatus();
		}
		#endregion

		#region Modify
		public void ShowModifyStatus()
		{
			BindCustomerAttendee();
			BindALAttendee();

			this.CustomerPaneImg.Visible = true;
			this.ALPaneImg.Visible = true;
			this.tbRequestedDateFrom.Visible = true;
			this.tbRequestedDateTo.Visible = true;
			this.RequestedDateFromspan.Visible = true;
			this.tbRequestedDateToSpan.Visible = true;

			this.lbRequestedDateFromReadOnly.Visible = false;
			this.lbRequestedDateToReadOnly.Visible = false;

			this.tbRequestedDateFrom.Text = this.lbRequestedDateFromReadOnly.Text;
			this.tbRequestedDateTo.Text = this.lbRequestedDateToReadOnly.Text;

			this.dgCustomerList.Columns[6].Visible = true;
			this.dgALAttendee.Columns[3].Visible = true;
		}

		public void EndModifyStatus()
		{
			Session[SessionFlag.CustomerSessionEZ] = null;
			Session[SessionFlag.AccompanySessionEZ] = null;

			this.ALPaneImg.Visible = false;
			this.CustomerPaneImg.Visible = false;
			this.tbRequestedDateFrom.Visible = false;
			this.tbRequestedDateTo.Visible = false;
			this.RequestedDateFromspan.Visible = false;
			this.tbRequestedDateToSpan.Visible = false;

			this.lbRequestedDateFromReadOnly.Visible = true;
			this.lbRequestedDateToReadOnly.Visible = true;

			this.lbRequestedDateFromReadOnly.Text =this.tbRequestedDateFrom.Text;
			this.lbRequestedDateToReadOnly.Text = this.tbRequestedDateTo.Text;

			this.dgCustomerList.Columns[6].Visible = false;
			this.dgALAttendee.Columns[3].Visible = false;
		}

		public void BuildModificationChange(ref Application app, ref IList customerAttendee, ref IList alAttendee)
		{
			if(this.tbRequestedDateFrom.Text!="")
			{
				app.RequestedDateFrom = Convert.ToDateTime(this.tbRequestedDateFrom.Text);
			}
			if(this.tbRequestedDateTo.Text!="")
			{
				app.RequestedDateTo = Convert.ToDateTime(this.tbRequestedDateTo.Text);
			}
			
			// Customer Attendee Info
//			DataTable table = (DataTable)this.dgCustomerList.DataSource;
//			if(table != null && table.Rows.Count > 0)
//			{
//				for(int i=0;i<table.Rows.Count;i++)
//				{
//					CustomerAttendee cus = new CustomerAttendee();
//					cus.NameEN = table.Rows[i]["Name"].ToString();
//					cus.Title = table.Rows[i]["Title"].ToString();
//					cus.Company = table.Rows[i]["Company"].ToString();			
//					cus.NameCN = table.Rows[i]["NameCN"].ToString();
//					cus.TitleEN = table.Rows[i]["TitleEN"].ToString();
//					cus.CompanyEN = table.Rows[i]["CompanyEN"].ToString();				
//					cus.Responsibility = new DicItem();
//					cus.Responsibility.Id =	Convert.ToInt32(table.Rows[i]["ResponsibilityID"]);
//					cus.Affects = new DicItem();
//					cus.Affects.Id = Convert.ToInt32(table.Rows[i]["AffectsID"]);
//					cus.IsAttended = true;
//
//					cus.Remark = table.Rows[i]["Remark"].ToString();
//					cus.IsExisted = Convert.ToInt32(table.Rows[i]["IsExisted"]);
//
//					customerAttendee.Add(cus);
//				}
//			}

			DataTable table = (DataTable)this.dgCustomerList.DataSource;
			if(table != null && table.Rows.Count > 0)
			{
				for(int i=0;i<table.Rows.Count;i++)
				{
					CustomerAttendee cus = new CustomerAttendee();
					cus.NameEN = table.Rows[i]["Name"].ToString();
					cus.Title = table.Rows[i]["Title"].ToString();
					cus.Company = table.Rows[i]["Company"].ToString();		
					cus.NameCN = table.Rows[i]["NameCN"].ToString();
					cus.TitleEN = table.Rows[i]["TitleEN"].ToString();
					cus.CompanyEN = table.Rows[i]["CompanyEN"].ToString();		
					cus.Responsibility = new DicItem();
					cus.Responsibility.Id =	Convert.ToInt32(table.Rows[i]["ResponsibilityID"]);
					cus.Affects = new DicItem();
					cus.Affects.Id = Convert.ToInt32(table.Rows[i]["AffectsID"]);
					cus.IsAttended = true;

					cus.Remark = table.Rows[i]["Remark"].ToString();
					cus.IsExisted = Convert.ToInt32(table.Rows[i]["IsExisted"]);

					customerAttendee.Add(cus);
				}
			}

			// AL Attendee Info
			table = (DataTable)this.dgALAttendee.DataSource;
			if(table != null && table.Rows.Count > 0)
			{
				for(int i=0;i<table.Rows.Count;i++)
				{
					ALAttendee al = new ALAttendee();
					al.EmployeeId = new Employee();
					al.EmployeeId.Id = table.Rows[i]["EmployeeId"].ToString();
					al.Title = table.Rows[i]["Title"].ToString();
			
					alAttendee.Add(al);
				}
			}
		}
		#endregion
	}
}
